c language output finding
c language output finding
1)#include <stdio.h>
int main()
{
int x = 400, y, z;
if (x >= 500)
y = 400;
z = 300;
printf("%d %d\n", y, z);
return 0;
}
2) #include <stdio.h>
int main()
{
int p = 800, q, r;
if (p >= 700)
q = 600;
r = 500;
printf("%d %d\n", q, r);
return 0;
}
3)#include <stdio.h>
int main()
{
int a = 30, b = 40;
if (a == b);
return 0;
}
4)#include <stdio.h>
int main()
{
int e = 4;
float f = 4.0;
if (e == f) {
printf("E and F are equal\n");
}
else {
printf("E and F are not equal");
}
return 0;
}
5)#include <stdio.h>
int main()
{
int p = 4, q, r;
q = p = 15;
r = p < 15;
printf("p = %d q = %d r = %d\n", p, q, r);
return 0;
}
6)#include <stdio.h>
int main()
{
int i = 65;
char j = 'A';
if (i == j) {
else {
printf("This place is not beautiful\n");
}
return 0;
}
7)#include <stdio.h>
int main()
{
float p = 13.25, q = 14.5;
if (p = q) {
printf("Hello\n");
}
return 0;
}
8)#include <stdio.h>
int main()
{
int k = 14, l = 12;
if (l >= k)
{
l = k;
k = l;
printf("%d, %d\n", k, l);
}
return 0;
}
9)#include <stdio.h>
int main()
{
if ('Y' < 'y') {
printf("ASCII value of Y is smaller than that of y\n");
}
else {
printf("ASCII value of y is smaller than that of Y\n");
}
return 0;
}
#include <stdio.h>
int main()
{
int r, s, c;
c = scanf("%d%d", &r, &s);
if (r + s - c) {
printf("This is a game");
}
else {
printf("you have to play it");
}
return 0;
}
13)#include <stdio.h>
int main()
{
printf("%s\n",4+"Hello world");
printf("%s\n","Hello world"+4);
return 0;
}
2)#include <stdio.h>
#include <string.h>
int main()
{
char str[]="Hello";
str[strlen(str)+1]='#';
printf("str= %s\n",str);
return 0;
}
14)#include <stdio.h>
int main()
{
char str[]={0x41,0x42,0x43,0x20,0x44,0x00};
printf("str= %s\n",str);
return 0;
}
15)#include <stdio.h>
int main()
{
char str[]="Hello";
char *ptr=str;
while(*ptr!='\0')
printf("%c",++*ptr++);
printf("\n");
return 0;
}
16)#include <stdio.h>
int main()
{
char str[5]={0},loop=0;
while(loop<5)
printf("%02X ",str[loop++]);
printf("\n");
return 0;
}
17) In C, what will be the output of the given code?
#include <stdio.h>
#include <string.h>
int main()
{
char *s1, *s2;
s1= "abcdef" ;
s2= "abcdeg" ;
printf(" %d ", strcmp (s1,s2));
printf(", ");
s1="abcdef";
s2="abcdef";
printf(" %d ", strcmp (s1,s2));
printf(", ");
s1="abcdef";
s2="abcdee";
printf(" %d ", strcmp (s1,s2));
printf(", ");
return 0;
}
18) Which function is used to find the last occurrence of character in C?
#include <stdio.h>
#include <string.h>
int main()
{
char document[] = "I love IncludeHelp.com This is an amazing website ";
char *s, *p ;
char character2 = 'x', character1 = 't';
s = strrchr(document, character1 );
p = strrchr(document, character2 );
if (s)
printf("The position of '%c' is %d\n", character1, s-document);
else
printf("The character was not found in given document\n");
if (p)
printf("The position of '%c' is %d\n", character2 , p-document);
else
printf("The character was not found in given document\n");
return 0;
}
19) In C, what will be the output of following program?
#include <stdio.h>
#include <string.h>
int main()
{
char a[] = "%d\n";
a[5] = 'i';
printf(a, 85);
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
char a[] = "Include Help";
char *b = "Include Help";
return 0;
}