NEW
Font size
WorksheetsC Program
Total questions: 20
Worksheet time: 11mins
What is the Format specifier used to print a String or Character array in C Printf or Scanf function.?
%c
%C
%s
%w
Find the Output for the Following code:
#include <stdio.h>
void main()
{
printf("""Hello World""");
}
""Hello World""
Hello World
"Hello World"
error
How do you convert this char array to string.?
char str[]={'g','l','o','b','y'};
A) str[5] = 0;
B) str[5] = '\0'
C) str[]={'g','l','o','b','y','\0'};
D) All the above
D
A
B
C
Find the Output for the Following code:
#include <stdio.h>
int main()
{
int c=5,s=0;
while(c<10)
{
c=c+1;
s=s-2;
}
printf("%d",s);
return 0;
}
10
5
-10
0
Find how many stars will be printed for below code:
#include <stdio.h>
int main()
{
int a=0;
while(a<25){
if(a>0 || a<=10)
{
printf("*");
}
else if(a>10 || a<=20)
{
printf("*");
}
else if(a>20 || a<=30)
{
printf("*");
}
a++;
}
return 0;
}
35 stars
25 stars
30 stars
20 stars
What is the maximum length of a C String.?
A) 32 characters
B) 64 characters
C) 256 characters
D) None of the above
A
B
C
D
Find the Output for the Following code:
#include <stdio.h>
int main()
{
int a=0,b=1;
while(a<=10)
{
printf("%d",a);
a=a+2;
a=a-b;
}
return 0;
}
012345678910
12345678910
0123456789
error
Find the Output for the Following code:
#include <stdio.h>
int main()
{
int i=1;
for(int i=1;i<=5;i++);
{
printf("%d ",i);
}
printf("Hello");
return 0;
}
1 Hello
12345 Hello
Hello
No ouput
Choose a correct C Statement about Strings.
A) PRINTF is capable of printing a multi word string.
B) PUTS is capable of printing a multi word string.
C) GETS is capable of accepting a multi word string from console or command prompt
D) All the above
D
C
B
A
Find the Output for the Following code:
#include <stdio.h>
int main()
{
int a=1;
do{
printf("%d",a);
}while(a);
return 0;
}
1
No output
infinity
error
Find the Output for the Following code:
#include <stdio.h>
int main()
{
int a=1,b=0;
do{
printf("Hello\n");
a=a+2;
b=a-a;
}while(b>0);
return 0;
}
Hello
infinity
Hello
Hello
Hello
Hello
Hello
Hello
In C, function primarily used for?
A. Decision making
B. Variable declaration
C. Code organization and reusability
D. Printing output
C
D
A
B
Find the Output for the Following code:
#include <stdio.h>
int main()
{
int a=1;
switch(a);
{
case 1:
printf("One");
break;
case 2:
printf("Two");
break;
default:
printf("Enter <2");
break;
}
return 0;
}
Error
One
Two
Enter <2
Find the Output for the Following code:
#include <stdio.h>
int main()
{
int arun=100,vijay=200;
int a=10,b=20;
int
temp=arun;
arun=vijay;
vijay=temp;
while(a<b && b>a)
{
if(arun==150 && vijay==150)
{
printf("* ");
break;
}
else
{
arun=arun-vijay+50;
vijay=arun;
continue;
printf("* * ");
}
}
printf("%d %d",arun,vijay);
return 0;
}
* 150 150
150 150 *
150 150
*150150
What are the types of functions in C Language?
a) Library Functions
b) User Defined Functions
c) Both Library and User Defined
d) None of the above
A
C
D
B
Find the Output for the Following code:
#include <stdio.h>
int main()
{
int arr[20]={10,20,30,40,50};
int i=0;
int *ptr=arr;
i+=3;
printf("%d",*(ptr+i));
return 0;
}
10
20
30
40
Find the Output for the Following code:
#include <stdio.h>
#include<string.h>
int main()
{
char str[]={'h','e','l','l','o','\0'};
int length=strlen(str);
char *ptr=str;
for(int i=0;i<=length-1;i++)
{
if(str[i]==str[i+1])
{
printf("I found Duplicate letter when i is = %d",i);
}
continue;
}
return 0;
}
1
2
3
Null
Every C Program should contain which function?
a) printf()
b) show()
c) scanf()
d) main()
D
A
B
C
Find the Output for the Following code:
#include <stdio.h>
void add(int a,int b)
{
int c=a+b;
printf("%d\n",c);
}
int main()
{
int a=10,b=20;
add(a,b);
a=5,b=5;
add(a,b);
return 0;
}
30
10
20
10
20
30
10
30
Choose a corrects statement about C language function arguments.
a) Number of arguments should be same when sending and receiving
b) Type of each argument should match exactly
c) Order of each argument should be same
d) All the above
A
B
C
D
