Monday, March 27, 2017
Write a program that will take a string and count ' a '
#include<stdio.h>
#include<string.h>
main()
{
int i,j,count=0;
char str1[100],str2[100];
printf("Enter first string ");
write a program that will take 2 string from user and concatenate the 2nd string after first string
#include<stdio.h>
#include<string.h>
main()
{
int i,j;
char str1[100],str2[100];
printf("Enter first string ");
gets(str1);/// str1 = "We"
#include<string.h>
main()
{
int i,j;
char str1[100],str2[100];
printf("Enter first string ");
gets(str1);/// str1 = "We"
write a program that will take 2 string from user and copy the string into first string
#include<stdio.h>
main()
{
int i;
char str1[100],str2[100];
printf("Enter first string ");
gets(str1);/// str1 = "We"
main()
{
int i;
char str1[100],str2[100];
printf("Enter first string ");
gets(str1);/// str1 = "We"
write a program that will show the max value in an array using function
#include<stdio.h>
void maximum(int array[],int i)
{
int max = array[0];///3
int min = array[0];///3
void maximum(int array[],int i)
{
int max = array[0];///3
int min = array[0];///3
Sunday, March 26, 2017
Array input and out and sum using function in c
///Array display using function
///write a program that will print their value and sum
#include<stdio.h>
int arrayDisplay(int b[],int i)
{
int sum =0;
for(i=0;i<5;i++)
{
printf("%d ",b[i]);
sum =sum + b[i];
}
// printf("\nsum = %d\n",sum);
return sum ;
}
void main()
{
int a[]={3,4,5,6,7},i;
printf("sum =%d",arrayDisplay(a,i));
}
Function in c with return example
/// write a program that will take two
///integers and find out their summation
///in add() function and also the subtraction in sub() function
#include<stdio.h>
int add(int a, int b )
{
return a + b ;
}
int sub(int a,int b)
{
return a-b;
}
void main()
{
scanf("%d%d",&a,&b);
printf("Summation = %d \n",add(a,b));
printf("subtraction = %d \n",sub(a,b));
}
///integers and find out their summation
///in add() function and also the subtraction in sub() function
#include<stdio.h>
int add(int a, int b )
{
return a + b ;
}
int sub(int a,int b)
{
return a-b;
}
void main()
{
scanf("%d%d",&a,&b);
printf("Summation = %d \n",add(a,b));
printf("subtraction = %d \n",sub(a,b));
}
Add sub and multiplication example in c with function 3
#include<stdio.h>
void add(int x ,int b,char letter)
{
printf("summation=%d \n",x+b);
}
void sub(int x,int y)
{
printf("subtraction=%d \n",x-y);
}
multi(int p,int q,float r)
{
printf("multiplication=%f \n",p*q*r);
}
void main()
{
printf("We R in main function \n");
int a,b;
printf("Enter 2 value \n");
scanf("%d%d",&a,&b);
add(a,b,'A'); ///parameter = pass by value
sub(a,b);
multi(a,b,8.5);
}
void add(int x ,int b,char letter)
{
printf("summation=%d \n",x+b);
}
void sub(int x,int y)
{
printf("subtraction=%d \n",x-y);
}
multi(int p,int q,float r)
{
printf("multiplication=%f \n",p*q*r);
}
void main()
{
printf("We R in main function \n");
int a,b;
printf("Enter 2 value \n");
scanf("%d%d",&a,&b);
add(a,b,'A'); ///parameter = pass by value
sub(a,b);
multi(a,b,8.5);
}
Subscribe to:
Posts (Atom)