Вы находитесь на странице: 1из 40

Write a c program to print Hello world without

using any semicolon.


Swap two variables without using third variable.

What is dangling pointer in c?

If any pointer is pointing the memory address of any variable but after some
variable has deleted from that memory location while pointer is still pointing such
memory location. Such pointer is known as dangling pointer and this problem is
known as dangling pointer problem.

Initially:

Later:

#include<stdio.h>

int *call();
int main(){

int *ptr;
ptr=call();

fflush(stdin);
printf("%d",*ptr);
return 0;
}
int * call(){

int x=25; // static int x=25


++x;

return &x;
}

What is wild pointer in c?


A pointer in c which has not been initialized is known
as wild pointer.

Example:

What will be output of following c program?

int main(){
int *ptr;
printf("%u\n",ptr);
printf("%d",*ptr);
return 0;
}

Output: Any address


Garbage value

Do you know memory representation of int a = 7 ?

Array of pointers in c:

Array whose content is address of another variable is


known as array pointers. For example:

int main(){
float a=0.0f,b=1.0f,c=2.0f;
float * arr[]={&a,&b,&c};
b=a+c;
printf("%f",arr[1]);
return 0;
}

Prototype of a function

Declaration of function is known as prototype of a


function. Prototype of a function means
(1) What is return type of function?
(2) What parameters are we passing?
(3) For example prototype of printf function is:

int printf(const char *, );

Write a c program to modify the constant variable


in c?

You can modify constant variable with the help of


pointers. For example:

#include<stdio.h>
int main(){
int i=10;
int *ptr=&i;
*ptr=(int *)20;
printf("%d",i);
return 0;
}

What is pointer to a function?


(1) What will be output if you will execute following
code?
int * function();
int main(){
auto int *x;
int *(*ptr)();
ptr=&function;
x=(*ptr)();
printf("%d",*x);
}
int *function(){
static int a=10;
return &a;
}

Output: 10
Explanation: Here function is function whose parameter
is void data type and return type is pointer to int
data type.

x=(*ptr)()
=> x=(*&functyion)() //ptr=&function
=> x=function() //From rule *&p=p
=> x=&a
So, *x = *&a = a =10

(2) What will be output if you will execute following


code?

int find(char);
int(*function())(char);
int main(){
int x;
int(*ptr)(char);
ptr=function();
x=(*ptr)('A');
printf("%d",x);
return 0;
}
int find(char c){
return c;
}
int(*function())(char){
return find;
}

Output: 65
Explanation: Here function whose name is function which
passing void data type and returning another function
whose parameter is char data type and return type is
int data type.
x=(*ptr)(A)
=> x= (*function ()) (A) //ptr=function ()
//&find=function () i.e. return type of function ()
=> x= (* &find) (A)
=> x= find (A) //From rule*&p=p
=> x= 65

(3) What will be output if you will execute following


code?

char * call(int *,float *);


int main(){
char *string;
int a=2;
float b=2.0l;
char *(*ptr)(int*,float *);
ptr=&call;
string=(*ptr)(&a,&b);
printf("%s",string);
return 0;
}
char *call(int *i,float *j){
static char *str="c-pointer.blogspot.com";
str=str+*i+(int)(*j);
return str;
}

Output: inter.blogspot.com
Explanation: Here call is function whose return type is
pointer to character and one parameter is pointer to
int data type and second parameter is pointer to float
data type and ptr is pointer to such function.
str= str+*i+ (int) (*j)
=c-pointer.blogspot.com + *&a+ (int) (*&b)
//i=&a, j=&b
=c-pointer.blogspot.com + a+ (int) (b)
=c-pointer.blogspot.com +2 + (int) (2.0)
=c-pointer.blogspot.com +4
=inter.blogspot.com
(4) What will be output if you will execute following
code?

char far * display(char far*);


int main(){
char far* string="cquestionbank.blogspot.com";
char far *(*ptr)(char far *);
ptr=&display;
string=(*ptr)(string);
printf("%s",string);
}
char far *display(char far * str){
char far * temp=str;
temp=temp+13;
*temp='\0';
return str;
}

Output: cquestionbak
Explanation: Here display is function whose parameter
is pointer to character and return type is also pointer
to character and ptr is its pointer.

temp is char pointer


temp=temp+13
temp=\0

Above two lines replaces first dot character by null


character of string of variable string i.e.
"cquestionbank\0blogspot.com"

As we know %s print the character of stream up to null


character.
Write a c program to find size of
structure without using sizeof operator?

struct ABC{
int a;
float b;
char c;
};
int main(){
struct ABC *ptr=(struct ABC *)0;
ptr++;
printf("Size of structure is: %d",*ptr);
return 0;
}

What is NULL pointer?


Literal meaning of NULL pointer is a pointer which is
pointing to nothing. NULL pointer points the base
address of segment.

Examples of NULL pointer:

1. int *ptr=(char *)0;


2. float *ptr=(float *)0;
3. char *ptr=(char *)0;
4. double *ptr=(double *)0;
5. char *ptr=\0;
6. int *ptr=NULL;

What will be output of following c program?

#include "stdio.h"
int main(){
#ifndef NULL
#define NULL 5
#endif
printf("%d",NULL+sizeof(NULL));
}

Output: 2
Pass by reference: In this approach we pass memory
address actual variables in function as a parameter.
Hence any modification on parameters inside the
function will reflect in the actual variable. For
example:

#incude<stdio.h>
int main(){
int a=5,b=10;
swap(&a,&b);
printf("%d %d",a,b);
return 0;
}
void swap(int *a,int *b){
int *temp;
*temp =*a;
*a=*b;
*b=*temp;
}

What is size of void pointer?


size of all type of pointer (near) in c is two
byte either it is char pointer, double pointer,
function pointer or null pointer. Void pointer is
not exception of this rule and size of void
pointer is also two byte.
What is difference between uninitialized pointer and
null pointer?

An uninitialized pointer is a pointer which points


unknown memory location while null pointer is pointer
which points a null value or base address of segment.
For example:
int *p; //Uninitialized pointer
int *q= (int *)0; //Null pointer
#include<stdio.h>
int *r=NULL; //Null pointer

Can you read complex pointer declaration?

Rule 1. Assign the priority to the pointer declaration


considering precedence and associative according to
following table.

(): This operator behaves as bracket operator or


function operator.

[]: This operator behaves as array subscription


operator.

*: This operator behaves as pointer operator not as


multiplication operator.

Identifier: It is not an operator but it is name of


pointer variable. You will always find the first
priority will be assigned to the name of pointer.

Data type: It is also not an operator. Data types also


includes modifier (like signed int, long double etc.)
You will understand it better by examples:

(1) How to read following pointer?

char (* ptr)[3]

Answer:
Step 1: () and [] enjoys equal precedence. So rule of
associative will decide the priority. Its associative
is left to right so first priority goes to ().

Step 2: Inside the bracket * and ptr enjoy equal


precedence. From rule of associative (right to left)
first priority goes to ptr and second priority goes to
*.

Step3: Assign third priority to [].


Step4: Since data type enjoys least priority so assign
fourth priority to char.

Now read it following manner:

ptr is pointer to such one dimensional array of size


three which content char type data.

(2) How to read following pointer?

float (* ptr)(int)

Answer:
Assign the priority considering precedence and
associative.

Now read it following manner:


ptr is pointer to such function whose parameter is int
type data and return type is float type data.

Rule 2: Assign the priority of each function parameter


separately and read it also separately. Understand it
through following example.

(3) How to read following pointer?

void (*ptr)(int (*)[2],int (*) void))

Answer:
Assign the priority considering rule of precedence
and associative.

Now read it following manner:

ptr is pointer to such function which first parameter


ispointer to one dimensional array of size two which
contentint type data and second parameter is pointer to
such function which parameter is void and return type
is int data type and return type is void.

(4) How to read following pointer?

int ( * ( * ptr ) [ 5 ] ) ( )

Answer:
Assign the priority considering rule of precedence
and associative.

Now read it following manner:


ptr is pointer to such array of size five which content
are pointer to such function which parameter is void
and return type is int type data.

(5) How to read following pointer?

double*(*(*ptr)(int))(double **,char c)

Answer:
Assign the priority considering rule of precedence and
associative.

Now read it following manner:

ptr is pointer to function which parameter is int type


data and return type is pointer to function which first
parameter is pointer to pointer of double data type and
second parameter is char type data type and return type
ispointer to double data type.

(6) How to read following pointer?

unsigned **(*(*ptr)[8](char const *, ...)

Answer:
Assign the priority considering rule of precedence and
associative.
Now read it following manner:

ptr is pointer to array of size eight and content of


array is pointer to function which first parameter is
pointer to character constant and second parameter is
variable number of arguments and return type
is pointer to pointer ofunsigned int data type.

What is the far pointer in c?

The pointer which can point or access whole the


residence memory of RAM i.e. which can access all 16
segments is known as far pointer.
Size of far pointer is 4 byte or 32 bit. Examples:

(1) What will be output of following c program?

int main(){
int x=10;
int far *ptr;
ptr=&x;
printf("%d",sizeof ptr);
return 0;
}

Output: 4

(2)What will be output of following c program?

int main(){
int far *near*ptr;
printf("%d %d",sizeof(ptr) ,sizeof(*ptr));
return 0;
}

Output: 4 2
Explanation: ptr is far pointer while *ptr is near
pointer.

(3)What will be output of following c program?

int main(){
int far *p,far *q;
printf("%d %d",sizeof(p) ,sizeof(q));
}

Output: 4 4

First 16 bit stores: Segment number


Next 16 bit stores: Offset address
Example:

int main(){
int x=100;
int far *ptr;
ptr=&x;
printf("%Fp",ptr);
return 0;
}

Output: 8FD8:FFF4
Here 8FD8 is segment address and FFF4 is offset address
in hexadecimal number format.

Note: %Fp is used for print offset and segment address


of pointer in printf function in hexadecimal number
format.
In the header file dos.h there are three macro
functions to get the offset address and segment address
from far pointer and vice versa.

1. FP_OFF(): To get offset address from far address.


2. FP_SEG(): To get segment address from far address.
3. MK_FP(): To make far address from segment and offset
address.

Examples:
(1)What will be output of following c program?

#include "dos.h"
int main(){
int i=25;
int far*ptr=&i;
printf("%X %X",FP_SEG(ptr),FP_OFF(ptr));
}

Output: Any segment and offset address in hexadecimal


number format respectively.

(2)What will be output of following c program?


#include "dos.h"
int main(){
int i=25;
int far*ptr=&i;
unsigned int s,o;
s=FP_SEG(ptr);
o=FP_OFF(ptr);
printf("%Fp",MK_FP(s,o));
return 0;
}

Output: 8FD9:FFF4 (Assume)


Note: We cannot guess what will be offset address;
segment address and far address of any far pointer
.These address are decided by operating system.

Limitation of far pointer:

We cannot change or modify the segment address of given


far address by applying any arithmetic operation on it.
That is by using arithmetic operator we cannot jump
from one segment to other segment. If you will
increment the far address beyond the maximum value of
its offset address instead of incrementing segment
address it will repeat its offset address in cyclic
order.

Example:

(q)What will be output of following c program?

int main(){
int i;
char far *ptr=(char *)0xB800FFFA;
for(i=0;i<=10;i++){
printf("%Fp \n",ptr);
ptr++;
}
return 0;
}

Output:

B800:FFFA
B800:FFFB
B800:FFFC
B800:FFFD
B800:FFFE
B800:FFFF
B800:0000
B800:0001
B800:0002
B800:0003
B800:0004

This property of far pointer is called cyclic nature of


far pointer within same segment.

Important points about far pointer:

1. Far pointer compares both offset address and segment


address with relational operators.

Examples:

(1)What will be output of following c program?

int main(){
int far *p=(int *)0X70230000;
int far *q=(int *)0XB0210000;
if(p==q)
printf("Both pointers are equal");
else
printf("Both pointers are not equal");
return 0;
}

Output: Both pointers are not equal


(2)What will be output of following c program?

int main(){
int far *p=(int *)0X70230000;
int far *q=(int *)0XB0210000;
int near *x,near*y;
x=(int near *)p;
y=(int near *)q;
if(x==y)
printf("Both pointer are equal");
else
printf("Both pointer are not equal");
return 0;
}

Output: Both pointers are equal

2. Far pointer doesnt normalize.

What is a cyclic property of data type in c?


Explain with any example.

#include<stdio.h>
int main(){
signed char c1=130;
signed char c2=-130;
printf("%d %d",c1,c2);
return 0;
}

Output: -126 126 (why?)


This situation is known as overflow of signed char.
Range of unsigned char is -128 to 127. If we will
assign a value greater than 127 then value of variable
will be changed to a value if we will move clockwise
direction as shown in the figure according to number.
If we will assign a number which is less than -128 then
we have to move in anti-clockwise direction.

Frequentlyaskedcprogramsininterview
1. Writeacprogramtocheckgivennumberisperfectnumber
ornot.
while(i<n){
if(n%i==0)
sum=sum+i;
i++;
}

2. Write a c program to check given number is Armstrong


numberornot.
3.Writeacprogramtocheckgivennumberisprimenumberor
not.
4.Writeacprogramtocheckgivennumberisstrongnumberor
not.
while(num){
i=1,f=1;
r=num%10;

while(i<=r){
f=f*i;
i++;
}
sum=sum+f;
num=num/10;
}

5.Cprogramtocheckanumberisoddoreven.
6. Write a c program to check given number is palindrome
numberornot.
8.Writeacprogramtocheckgivenstringispalindromenumber
or not.
7.Writeacprogramtosolvequadraticequation.
d = b * b - 4 * a * c;

if(d < 0){


printf("Roots are complex number.\n");

printf("Roots of quadratic equation are: ");


printf("%.3f%+.3fi",-b/(2*a),sqrt(-d)/(2*a));
printf(", %.3f%+.3fi",-b/(2*a),-sqrt(-d)/(2*a));

return 0;
}
else if(d==0){
printf("Both roots are equal.\n");

root1 = -b /(2* a);


printf("Root of quadratic equation is: %.3f
",root1);
return 0;
}
else{
printf("Roots are real numbers.\n");

root1 = ( -b + sqrt(d)) / (2* a);


root2 = ( -b - sqrt(d)) / (2* a);
printf("Roots of quadratic equation are: %.3f ,
%.3f",root1,root2);
}

8.WriteacprogramtoprintFibonacciseriesofgivenrange.
for(k=2;k<r;k++){
f=i+j;
i=j;
j=f;
printf(" %ld",j);
}

9.Writeacprogramtogetfactorialofgivennumber.
10.WriteacprogramforFloydstriangle.
printf("FLOYD'S TRIANGLE\n\n");
for(i=1;i<=r;i++){
for(j=1;j<=i;j++,k++)
printf(" %d",k);
printf("\n");
}
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21

11.WriteacprogramtoprintPascaltriangle.
printf("Enter the no. of lines: ");
scanf("%d",&line);
for(i=0;i<line;i++){
for(j=0;j<line-i-1;j++)
printf(" ");

for(j=0;j<=i;j++)
printf("%ld ",fact(i)/(fact(j)*fact(i-
j)));
printf("\n");
}
return 0;
}

long fact(int num){


long f=1;
int i=1;
while(i<=num){
f=f*i;
i++;
}
return f;
}

Sample output:

Enter the no. of lines: 8


1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1

12. Write a c program to generate multiplication table.


13.WriteacprogramtoprintASCIIvalueofallcharacters.
14. C program to print hello world without using semicolon
15.Writeacprogramwhichproducesitsownsourcecodeasits
output
#include<stdio.h>

int main(){
FILE *fp;
char c;

fp = fopen(__FILE__,"r");

do{
c= getc(fp);
putchar(c);
}
while(c!=EOF);

fclose(fp);

return 0;
}

Cprogramwithnumbers

1.Writeacprogramtoreverseanynumber.
2.Writeacprogramtofindoutsumofdigitofgivennumber.
3. Writeacprogramtofindoutpowerofnumber.
while(i<=pow){
sum=sum*num;
i++;
}

4. Write a c program to add two numbers without using
additionoperator.
sum = a - ~b -1;
In c ~ is 1's complement operator. This is equivalent
to:
~a = -b + 1
So, a - ~b -1
= a-(-b + 1) + 1
= a + b 1 + 1
= a + b

5. Writeacprogramtosubtracttwonumberswithoutusing
subtractionoperator.
sum = a + ~b + 1;
6. Write a c program to find largest among three numbers
usingbinaryminusoperator.
7. if(a-b>0 && a-c>0)
8. printf("\nGreatest is a :%d",a);
9. else
10. if(b-c>0)
11. printf("\nGreatest is b :%d",b);
12. else
13. printf("\nGreatest is c :%d",c);

7.Writeacprogramtofindlargestamongthreenumbersusing
conditionaloperator
big=(a>b&&a>c?a:b>c?b:c);
printf("\nThe biggest number is: %d",big);

8.Writeacprogramtofindoutgenericrootofanynumber.
scanf("%d",&num);
printf("Generic root: %d",(x=num%9)?x:9);
Meaning of generic root:
It sum of digits of a number unit we don't get a single
digit. For example:
Generic root of 456: 4 + 5 + 6 = 15 since 15 is two
digit numbers so 1 + 5 = 6
So, generic root of 456 = 6

9.Writeacprogramtofindoutprimefactorofgivennumber.
10.WriteacprogramtofindoutNCRfactorofgivennumber.
ncr=fact(n)/(fact(r)*fact(n-r));
11.Howtoconvertstringtointwithoutusinglibraryfunctions
inc
#include<stdio.h>

int stringToInt(char[] );
int main(){

char str[10];
int intValue;

printf("Enter any integer as a string: ");


scanf("%s",str);

intValue = stringToInt(str);

printf("Equivalent integer value: %d",intValue);

return 0;
}

int stringToInt(char str[]){


int i=0,sum=0;

while(str[i]!='\0'){
if(str[i]< 48 || str[i] > 57){
printf("Unable to convert it into
integer.\n");
return 0;
}
else{
sum = sum*10 + (str[i] - 48);
i++;
}

return sum;

}
Sample output:
Enter any integer as a string: 123
Equivalent integer value: 123

12. Program in c to print 1 to 100 without using loop


13. C program for swapping of two numbers
14. Program to find largest of n numbers in c
15. Split number into digits in c programming
16.Cprogramtocountnumberofdigitsinanumber
Recursion

Exampleofrecursionincprogramming
#include<stdio.h>
#define MAX 100
char* getReverse(char[]);

int main(){

char str[MAX],*rev;

printf("Enter any string: ");


scanf("%s",str);

rev = getReverse(str);

printf("Reversed string is: %s",rev);


return 0;
}

char* getReverse(char str[]){

static int i=0;


static char rev[MAX];

if(*str){
getReverse(str+1);
rev[i++] = *str;
}

return rev;
}

Sample output:

Enter any string: mona


Reversed string is: anom

L.C.MandH.C.F.

1. WriteacprogramtofindoutL.C.M.oftwonumbers.
2. #include<stdio.h>
3. int main(){
4. int n1,n2,x,y;
5. printf("\nEnter two numbers:");
6. scanf("%d %d",&n1,&n2);
7. x=n1,y=n2;
8. while(n1!=n2){
9. if(n1>n2)
10. n1=n1-n2;
11. else
12. n2=n2-n1;
13. }
14. printf("L.C.M=%d",x*y/n1);
15. return 0;
16. }
17.
2. WriteacprogramtofindoutH.C.F.oftwonumbers.
3. #include<stdio.h>
4. int main(){
5. int n1,n2;
6. printf("\nEnter two numbers:");
7. scanf("%d %d",&n1,&n2);
8. while(n1!=n2){
9. if(n1>=n2-1)
10. n1=n1-n2;
11. else
12. n2=n2-n1;
13. }
14. printf("\nGCD=%d",n1);
15. return 0;
16. }
17.
3.WriteacprogramtofindoutG.C.D.oftwonumbers.
Swapping

1.Writeacprogramtoswaptwonumbers.
2.Writeacprogramtoswaptwonumberswithoutusingthird
variable.
3.Writeacprogramforswappingoftwoarrays.
4.Writeacprogramforswappingoftwostring.
Conversion(NumberSystem)

1. Writeacprogramtoconvertdecimalnumbertobinary
number.
2. quotient = decimalNumber;
3.
4.
5. while(quotient!=0){
6.
7. binaryNumber[i++]= quotient % 2;
8.
9. quotient = quotient / 2;
10.
11. }
12.
2. Write a c program to convert decimal number to octal
number.
while(quotient!=0){
octalNumber[i++]= quotient % 8;
quotient = quotient / 8;
}

3.Write a c program to convert decimal number


tohexadecimalnumber.
while(quotient!=0){
temp = quotient % 16;

//To convert integer into character


if( temp < 10)
temp =temp + 48;
else
temp = temp + 55;

hexadecimalNumber[i++]= temp;
quotient = quotient / 16;
}

printf("Equivalent hexadecimal value of decimal


number %d: ",decimalNumber);
for(j = i -1 ;j> 0;j--)
printf("%c",hexadecimalNumber[j]);

4.Writeacprogramtoconvertoctalnumbertobinarynumber.
5. Write a c program to convert octal number to decimal
number.
6.Writeacprogramtoconvertoctalnumbertohexadecimal
number.
7.Writeacprogramtoconverthexadecimalnumbertobinary
number.
scanf("%s",hexaDecimal);

printf("\nEquivalent binary value: ");


while(hexaDecimal[i]){
switch(hexaDecimal[i]){
case '0': printf("0000"); break;
case '1': printf("0001"); break;
case '2': printf("0010"); break;
case '3': printf("0011"); break;
case '4': printf("0100"); break;
case '5': printf("0101"); break;
case '6': printf("0110"); break;
case '7': printf("0111"); break;
case '8': printf("1000"); break;
case '9': printf("1001"); break;
case 'A': printf("1010"); break;
case 'B': printf("1011"); break;
case 'C': printf("1100"); break;
case 'D': printf("1101"); break;
case 'E': printf("1110"); break;
case 'F': printf("1111"); break;
case 'a': printf("1010"); break;
case 'b': printf("1011"); break;
case 'c': printf("1100"); break;
case 'd': printf("1101"); break;
case 'e': printf("1110"); break;
case 'f': printf("1111"); break;
default: printf("\nInvalid hexadecimal
digit %c ",hexaDecimal[i]); return 0;
}
i++;
}

return 0;
}

8.Writeacprogramtoconverthexadecimalnumbertooctal
number.
9.Writeacprogramtoconverthexadecimalnumbertodecimal
number.
10.Writeacprogramtoconvertbinarynumbertooctalnumber.
11. Write a c program to convert binary number to decimal
number.
13. Write a c program to convert binary number to
hexadecimal number.
13.C program for addition of binary numbers .
14.Cprogramformultiplicationoftwobinarynumbers.
15.Cprogramfractionalbinaryconversionfromdecimal.
16.C program for fractional decimal to binary fraction
conversion.
17. C program to convert decimal number to roman.
18. C program to convert roman number to decimal
number.
19.Cprogramtoconverteachdigitsofanumberinwords
14. while(number){
15.
16. digit = number %10;
17. number = number /10;
18.
19. switch(digit){
20. case 0: word[i++] = "zero"; break;
21. case 1: word[i++] = "one"; break;
22. case 2: word[i++] = "two"; break;
23. case 3: word[i++] = "three"; break;
24. case 4: word[i++] = "four"; break;
25. case 5: word[i++] = "five"; break;
26. case 6: word[i++] = "six"; break;
27. case 7: word[i++] = "seven"; break;
28. case 8: word[i++] = "eight"; break;
29. case 9: word[i++] = "nine"; break;
30.
31. }
32. }
33.
20.Cprogramtoconvertcurrencyornumberinword.

Conversion(Unit)
1.Cprogramforunitconversion.
String
1.Writeacprogramtoconvertthestringfromuppercaseto
lowercase.
2.Writeacprogramtoconvertthestringfromlowercaseto
uppercase.
3.Writeacprogramtodeletetheallconsonantsfromgiven
string.
4.Writeacprogramtocountthedifferenttypesofcharactersin
givenstring.
5.Writeacprogramtosortthecharactersofastring.
6.Writeacprogramforconcatenationtwostringswithoutusing
string.hheaderfile.
7.Writeacprogramtofindthelengthofastringusingpointer.
8.Writeacprogramwhichprintsinitialofanyname.
9.Writeacprogramtoprintthestringfromgivencharacter.
10. Write a c program to reverse a string
11. Reverse a string using recursion in c
12. String concatenation in c without using strcat
13. How to compare two strings in c without using strcmp
14. String copy without using strcpy in c
15.ConvertastringtoASCIIinc
Matrix

1.Writeacprogramforadditionoftwomatrices.
2.Writeacprogramforsubtractionoftwomatrices
3.Writeacprogramformultiplicationoftwomatrices.
4.Writeacprogramtofindoutsumofdiagonalelementofa
matrix.
5. Write a c program to find out transport of a matrix.
6. Write a c program for scalar multiplication of matrix.
7. C program to find inverse of a matrix
8. Lower triangular matrix in c
9. Upper triangular matrix in c
10. Strassen's matrix multiplication program in c
11.Cprogramtofinddeterminantofamatrix
File

1.Writeacprogramtoopenafileandwritesometextandclose
its.
2.Writeacprogramtodeleteafile.
3.Writeacprogramtocopyafilefromonelocationtoother
location.
4.Writeacprogramtocopyadataoffiletootherfile.
5.Writeacprogramwhichdisplaysourcecodeasaoutput.
6.Writeacprogramwhichwritesstringinthefile.
7.Writeacprogramwhichreadsstringfromfile.
8.Writeacprogramwhichwritesarrayinthefile.
9.Writeacprogramwhichconcatenatetwofileandwriteit
third file.
10. Write a c program to find out size of any file.
11. Write a c program to know type of file.
12. Write a c program to know permission of any file.
13.Writeacprogramtoknowlastdateofmodificationofany
file.
14.Writeacprogramtofindsizeanddriveofanyfile.
Complexnumber

1.Complexnumbersprograminc
2. Write a c program for addition and subtraction of two
complexnumbers.
3. Write a c program for multiplication of two complex
numbers.
4.Writeacprogramfordivisiontwocomplexnumbers.
Series

1.Writeacprogramtofindoutthesumofseries1+2+.+
n.
2.Writeacprogramtofindoutthesumofseries1^2+2^2+
.+n^2.
3.Writeacprogramtofindoutthesumofseries1^3+2^3+
.+n^3.
4.WriteacprogramtofindoutthesumofgivenA.P.
5.WriteacprogramtofindoutthesumofgivenG.P.
6.WriteacprogramtofindoutthesumofgivenH.P.
7.Writeacprogramtofindoutthesumofseries1+2+4+8
toinfinity.
Array

1.Writeacprogramtofindoutlargestelementofanarray.
2.Writeacprogramtofindoutsecondlargestelementofan
unsortedarray.
3.Writeacprogramtofindoutsecondsmallestelementofan
unsortedarray.
4.Writeacprogramwhichdeletestheduplicateelementofan
array.
5.Writeacprogramfordeleteanelementatdesiredpositionin
anarray.
6.Writeacprogramforinsertanelementatdesiredpositionin
an array.
7.Cprogramtofindlargestandsmallestnumberinanarray
Sorting

1.Writeacprogramforbubblesort.
2.Writeacprogramforinsertionsort.
3.Writeacprogramforselectionsort.
4.Writeacprogramforquicksort.
5.Writeacprogramforheapsort.
6.Writeacprogramformergesort.
7.Writeacprogramforshellsort.
Recursion

1. Write a c program to find factorial of a number using


recursion.
2. Write a c program to find GCD of a two numbers using
recursion.
3.Writeacprogramtofindoutsumdigitsofanumberusing
recursion.
4.Writeacprogramtofindpowerofanumberusingfunction
recursion.
5.Writeacprogramtoreverseanynumberusingrecursion.
Sizeofdatatype

1.Writeacprogramtofindthesizeofintwithoutusingsizeof
operator.
2.Writeacprogramtofindthesizeofdoublewithoutusing
sizeofoperator.
3.Writeacprogramtofindthesizeofstructurewithoutusing
sizeofoperator.
4.Writeacprogramtofindthesizeofunionwithoutusing
sizeofoperator.
Usingpointer

1.Writeacprogramforconcatenationtwostringusingpointer.
Searching

1.Writeacprogramforlinearsearch.
2.Writeacprogramforbinarysearch.
3.Writeacprogramforbinarysearchusingrecursion.
Areaandvolume

1.Writeacprogramtofindtheareaofcircle.
2. Write a c program to find the area of any triangle.
3.Write a c program to find the area of equilateral triangle.
4.Writeacprogramtofindtheareaofrightangledtriangle.
5.Writeacprogramtofindtheareaofrectangle.
6. Write a c program to find the area of trapezium.
7.Write a c program to find the area of rhombus.
8.Writeacprogramtofindtheareaofparallelogram.
9.Writeacprogramtofindthevolumeandsurfaceareaof
cube.
10.Writeacprogramtofindthevolumeandsurfaceareaof
cuboids.
11.Write a c program to find the volume and surface area
ofcylinder.
12.Writeacprogramtofindthesurfaceareaandvolumeofa
cone.
13.Writeacprogramtofindthevolumeandsurfaceareaof
sphere.
14.Writeacprogramtofindtheperimeterofacircle,rectangle
and triangle.

C program with very large numbers

1. Write a c program to find factorial of 100 or very large


numbers
2. Writeac programto multiplythe twoverylarge number
(larger the long int)
3.Writeacprogramfordivisionoflargenumber(largerthan
long int)
4. C code formodulardivisionof large number.
5. C code for division of large number.
6. C code for power of large numbers.

Other

1.CprogramforATMtransaction.
2. Write a c program which passes one dimension array to
function.
3. Write a c program which passes two dimension array to
function.
4.Writeacprogramwhichtakespasswordfromuser.
5.Writeascanffunctionincwhichacceptsentencefromuser.
6.Writeascanffunctionincwhichacceptparagraphfromuser.
7.Writeacprogramtoprinttheallprimenumbersbetween1to
300.
8. Write a c program which passes structure to function.
9. Palindrome in c without using string function
10. How to get the ASCII value of a character in c
11. C program to get last two digits of year
12.Cprogramwithoutmainfunction

Вам также может понравиться