0% found this document useful (0 votes)
22 views15 pages

C Programming Concepts and Errors

The document contains sample code snippets and questions related to C programming basics. Some questions ask the reader to identify errors in code, point out differences between arrays and pointers, explain code output, or complete code snippets to resolve errors. The document appears to be providing practice problems related to foundational C programming concepts like loops, functions, arrays, pointers, and basic syntax.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views15 pages

C Programming Concepts and Errors

The document contains sample code snippets and questions related to C programming basics. Some questions ask the reader to identify errors in code, point out differences between arrays and pointers, explain code output, or complete code snippets to resolve errors. The document appears to be providing practice problems related to foundational C programming concepts like loops, functions, arrays, pointers, and basic syntax.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

SKILL

REINFORCEMEN
T
LAB - 1
C - basics
What would the output of the following program?

main()
{
char a[] = "Visual C++";
char *b = "Visual C++";
printf("\n %d %d",sizeof(a),sizeof(b));
printf("\n %d %d",sizeof(*a),sizeof(*b));
}
What would be the output of the following program, if the array begins at
address 1200?

main()
{
int arr[] = {2,3,4,1,6};
printf("%d %d",arr, sizeof(arr));
}
Are the expressions arr and &arr same for an array of 10 integers ?
Would the following program compile successfully ?

main()
{
char a[] = "Sunstroke";
char *p = "Coldwave";
a = "Coldwave";
p = "Sunstroke";
printf("\n %s %s",a,p);
}
What does the follwoing declaration mean:

int(*ptr)[10];
What would be the output of the following program?
main()
{
int i = 4;
switch(i)
{
default:
printf("\n a mouse is an elephant built by the japanese.");
case 1:
printf("\n Breeding rabbits is a hare raising experience.");
case 2:
printf("\n Friction is drag.");
case3:
printf("\n If practice makes perfect, then nobody's perfect");
}
}
Point out the error, if any, in the for loop:

main()
{
int i = 1;
for( ; ; )
{
printf("%d",i++);
if (i > 10)
break;
}
}
Point out the error, if any, in the while loop:

main()
{
int i = 1;
while(i <= 5)
{
printf("%d",i);
if( i > 2)
goto here;
}
}
fun()
{
here:
printf("\n If it works, Don't fix it.");
}
Point out the error, if any, in the following program:

main()
{
int i = 10;
switch(a)
{
}
printf("Programmers never die. They just get lost in the processing.");
}
Point out the error,if any, in the following program:

main()
{
int i = 1;
switch(i)
{
printf("Hello");

case 1:
printf("\n Individualists unite.");
break;

case 2:
printf("\n Money is the root of all wealth.");
break;
}
}
What would be the output of the following program?

main()
{
int a,b;
a = sumdig(123);
b = sumdig(123);
printf(" %d %d",a,b);
}

sumdig(int n)
{
static int s = 0;
int d;
if( n != 0)
{
d = n % 10;
n = (n - d) / 10;
s = s + d;
sumdig(n);
}
else
return(s);
}
There is a mistake in the following code. Add a statement in it to remove it.

main()
{
int a;
a = f(10,3.14);
printf("%d",a);
}

f(int aa, float bb)


{
return ((float) aa + bb);
}
Will the following functions work? <Yes / No>

int f1(int a,int b)


{
return(f2(20));
}

int f2(int a)
{
return(a * a);
}
WIPRO :

Write a C program to convert the given binary number into decimal.

MINDTREE :
Remove all the vowels from a given string using pointers. (Easy)

Check if given two matrices are identical. (Medium)

Print the given matrix in spiral form. (Hard)

You might also like