Professional Documents
Culture Documents
3.
main()
{
register i=5;
char j[]= "hello";
printf("%s %d",j,i);
}
4.
main()
{
union std
{
int x;
int y;
};
union std s1;
s1.x =10;
s1.y =20;
printf("%d, %d\n",u.x, u.y);
return 0;
}
5.
# include <stdio.h>
int arr[]={1,2,3};
main()
{
int *ptr;
ptr = arr;
ptr = ptr+3;
printf("%d",*ptr);
}
6.
main()
{
long i = 30000;
printf("%d", i);
}
7.
main()
{
register i=5;
char j[]= "hello";
printf("%s %d",j,i);
}
8.
nt fun(int *a,int *b)
{
*a=*a+*b;
*b=*a-*b;
*a=*a-*b;
}
main()
{
int x=10,y=20;
fun(&x,&y);
printf("x= %d y = %d\n",x,y);
}
9.
main()
{
long i = 65536;
printf("%d\n", i);
}
10.
# define SQR(X) (X*X)
main()
{
int a, b = 3;
a = SQR(b+2);
printf("\n%d", a);
}
Q3. Write a C program to input 10 Student name, roll no and percentage and display
the same. (10 marks)
Q4. a). Write a C program to transpose row and column of matrix. (5 marks)
b). Write a C program to find sum of digit using recursion function. (5 marks)
Q5. Write the code for the following output: (15 marks)
1. K
K L
K L M
K L M N
K L M N O
2. 1
23
456
7 8 9 10
3. 1
01
101
0101
10101
Patt1
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
char ch='K';
clrscr();
for(i=1;i<=5;i++)
{
for(j=5-i;j>=1;j--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%c ",ch);
ch++;
}
ch='K';
printf("\n");
}
getch();
}
Patt2
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,c=1;
clrscr();
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",c);
c++;
}
printf("\n");
}
getch();
}
Patt3
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=i;j>=1;j--)
{
if(j%2!=0)
printf("1");
else
printf("0");
}
printf("\n");
}
getch();
}