SlideShare une entreprise Scribd logo
1  sur  23
STRING LAB REPORT
Q1. Write a program that will read a string and show each
character with one space.
 #include<stdio.h>
 int main ()
 {
 char ch[1000];
 int i;
 printf("ENTER A STRING:n");
 gets(ch);
 printf("WITH SPACE : n");
 for(i=0;ch[i]!='0';i++)
 {
 printf("%c ",ch[i]);
 }
 return 0;
 }
Q2. Write a program that will read a string and show each
character with one space in reverse order.
 #include<stdio.h>
 int main ()
 {
 char ch[1000];
 int i,j;
 printf("ENTER A STRING:n");
 gets(ch);
 printf("REVERS PRINT WITH SPACE : n");
 for(i=0;ch[i]!='0';i++);
 for(j=i-1;j>=0;j--)
 {
 printf("%c ",ch[j]);
 }
 return 0;
 }
Q3. Write a program that will read a string and show each
character in separate line.
 #include<stdio.h>
 int main ()
 {
 char ch[1000];
 int i;
 printf("ENTER A STRING:n");
 gets(ch);
 printf("EACH CHARACTER IN SEPARATE LINE: n");
 for(i=0;ch[i]!='0';i++)
 {
 printf("%cn",ch[i]);
 }
 return 0;
 }
Q4. Write a program that will read a string and show each
character and corresponding ASCII value in separate line.
 #include<stdio.h>
 int main ()
 {
 char ch[1000];
 int i;
 printf("ENTER A STRING:n");
 gets(ch);
 printf("EACH CHARACTER IN SEPARATE LINE WITH CORRESPONDING
ASCII VALUE: n");
 for(i=0;ch[i]!='0';i++)
 {
 printf("%ct%dn",ch[i],ch[i]);
 }
 return 0;
 }
Q5. Write a program that will read a string and show frequency of
every character in this string.
 #include<stdio.h>
 int main ()
 {
 char ch[1000];
 int i,count[26]={0};
 printf("ENTER A STRING:n");
 gets(ch);
 for(i=0;ch[i]!='0';i++)
 {
 if(ch[i]>='a'&&ch[i]<='z')
 count[ch[i]-'a']++;
 }
 for(i=0;i<26;i++)
 {
 if(count[i]!=0)
 printf("%c OCCURS %d TIME(S):n",i+'a',count[i]);
 }
 return 0;
 }
Q6. Write a program that will read a string and show the length of
that string.
 #include<stdio.h>
 int main ()
 {
 char ch[1000];
 int i;
 printf("ENTER A STRING:n");
 gets(ch);
 for(i=0;ch[i]!='0';i++);
 printf("LENGTH OF THE STRING IS : %d",i);
 return 0;
 }
Q7. Write a program that will read a string and show the string in
reverse order.
 #include<stdio.h>
 int main ()
 {
 char ch[1000];
 int i,j;
 printf("ENTER A STRING:n");
 gets(ch);
 printf("REVERS PRINT : n");
 for(i=0;ch[i]!='0';i++);
 for(j=i-1;j>=0;j--)
 {
 printf("%c",ch[j]);
 }
 return 0;
 }
Q8. Write a program that will read a string and copy this to
another string.
 #include<stdio.h>
 int main ()
 {
 char ch[100],st[100];
 int i,j;
 printf("ENTER A STRING:n");
 gets(ch);
 for(i=0;ch[i]!='0';++i)
 {
 st[i]=ch[i];
 }
 st[i]='0';
 puts(st);
 return 0;
 }
Q9. Write a program that will read two strings and add second
string with first string.
 #include<stdio.h>
 int main ()
 {
 char ch[100],st[100];
 printf("ENTER FIRST STRING:n");
 gets(ch);
 printf("ENTER SECOND STRING:n");
 gets(st);
 strcat(ch,st);
 printf("n%s",ch);
 return 0;
 }
Q10. Write a program that will read two strings and compare
which one is greater.
 #include<stdio.h>
 int main ()
 {
 char ch[1000],st[1000];
 int i,j;
 printf("ENTER FIRST STRING:n");
 gets(ch);
 for(i=0;ch[i]!='0';i++);
 printf("ENTER SECOND STRING:n");
 gets(st);
 for(j=0;st[j]!='0';j++);
 if(i>j) printf("STRING 1 IS GREATER");
 else printf("STRING 2 IS GREATER");
 return 0;
 }
Q11. Write a program that will read a string and convert all
lowercase letter to uppercase and all uppercase letter to
lowercase.
 #include<stdio.h>
 int main ()
 {
 int c;
 char ch,s[1000];
 printf("ENTER A STRINGn");
 gets(s);
 for(c=0;s[c]!='0';c++)
 {
 ch=s[c];
 if(ch >= 'A' && ch <= 'Z')
 s[c]= s[c]+32;
 else if(ch >= 'a' && ch <= 'z')
 s[c]= s[c]-32;
 }
 printf("%sn",s);
 return 0;
 }
FUNCTION PROBLEM
Q1. Write a function that gets two integers and returns sum.
 #include<stdio.h>
 int sum(int a, int b)
 {
 int result;
 result=a+b;
 return result;
 }
 int main ()
 {
 int x,y,res;
 printf("ENTER TWO NUMBERS:n");
 scanf("%d %d",&x,&y);
 res=sum(x,y);
 printf("SUM OF %d AND %d IS %d",x,y,res);
 return 0;
 }
Q2. Write a function that gets two integers and returns division.
 #include<stdio.h>
 int sum(int a, int b)
 {
 int result;
 result=a+b;
 return result;
 }
 int main ()
 {
 int x,y,res;
 printf("ENTER TWO NUMBERS:n");
 scanf("%d %d",&x,&y);
 res=sum(x,y);
 printf("SUM OF %d AND %d IS %d",x,y,res);
 return 0;
 }
Q3. Write a function that gets length and width of a
rectangle and returns area
 #include<stdio.h>
 int result;
 int mul(int a, int b)
 {

 result=a*b;
 return result;
 }
 int main ()
 {
 int x,y;
 printf("ENTER LENGTH OF THE RECTANGLE:n");
 scanf("%d",&x);
 printf("ENTER HIGHT OF THE RECTANGLE:n");
 scanf("%d",&y);
 mul(x,y);
 printf("AREA OF THE RECTANGLE IS %d SQUARE UNIT",result);
 return 0;
 }
Q4. Write a function that gets radius of a circle and
returns area.
 #include<stdio.h>


 void ara(float x)
 {
 float result;
 float pi=3.1416;
 result=pi*x*x;
 printf("AREA OF THE CIRCLE IS %.3f SQUARE UNIT",result);
 }
 int main ()
 {
 float r;
 printf("ENTER THE RADIOUS OF THE CIRCLE :n");
 scanf("%f",&r);
 ara(r);

 return 0;
 }
Q5. Write a function that gets any positive integer and
returns its factorial.
 #include<stdio.h>

 int fac(int x)
 {
 int i,j=1;
 for (i=1;i<=x;i++)
 {

 j=j*i;

 }
 return j;
 }
 int main ()
 { int y,z;
 printf("ENTER A NUMBERn");
 scanf("%d",&y);
 if(y>=0)
 {
 z=fac(y);
 printf("FACTORIAL OF %d IS %d",y,z);
 }
 else printf("Number is negative");
 return 0;
 }
Q6. Write a function that gets any positive integer and
returns its reverse
 #include<stdio.h>
 int revrs(int num)
 {
 int reminder,reverse=0,res;
 while(num>0)
 {
 reminder = num%10;
 num = num/10;
 reverse = reverse*10+reminder;

 }
 return reverse;
 }
 int main()
 {
 int a,res;
 printf("Enter a positive integer number: ");
 scanf("%d",&a);
 if(a<0)
 {
 printf("Number is negativen");
 } else
 {
 res = revrs(a);
 printf("%d",res);
 }
 return 0;
 }
Q7. Write a function that gets two positive integers and
returns LCM (Least Common Multiple).
 #include<stdio.h>
 void lcm(int x,int y)
 {
 int i=1;

 while(i>0)
 {
 if(i%x==0 && i%y==0)
 {
 printf("THE LCM OF %d AND %d IS %d",x,y,i);
 break;

 }i++;
 }
 }
 int main ()
 {
 int p,q;
 scanf("%d %d",&p,&q);
 lcm(p,q);
 }
Q8. Write a function that gets two positive integers and
returns nCr.
 #include<stdio.h>
 int fac(int x)
 {
 int i,j=1;
 for (i=1;i<=x;i++)
 {

 j=j*i;

 }
 return j;
 }

 int main()
 {
 int n,m,o,p,q,r,s;
 printf("ENTER n:n");
 scanf("%d",&n);
 printf("ENTER r:n");
 scanf("%d",&r);
 o=fac(r);
 m=fac(n);
 p=(n-r);
 q=fac(p);
 if(n>=0 && r >=0 && n>=r){
 s=m/(q*o);
 printf("%dC%d = %d",n,r,s);
 }
 else printf("MATH ERROR");
 }
Q9. Write a function that gets any positive integer and
determine prime or not prime.
 #include<stdio.h>
 int prime=0;
 void pri(int x)
 {
 int i;
 for(i=2;i<=x/2;i++)
 {
 if(x%i==0)
 {
 prime=1;
 break;
 }
 }
 if(prime==0) printf("%d IS A PRIME NUMBER",x);
 else printf("%d IS NOT A PRIME NUMBER",x);


 }
 int main()
 {
 int n;

 scanf("%d",&n);
 pri(n);

 }

Contenu connexe

Tendances

Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 

Tendances (20)

3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
 
Pnno
PnnoPnno
Pnno
 
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solutionLet us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
 
Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
C file
C fileC file
C file
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Vcs17
Vcs17Vcs17
Vcs17
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
 
Lecture 1 string functions
Lecture 1  string functionsLecture 1  string functions
Lecture 1 string functions
 

En vedette

Updated Cyber Security and Fraud Prevention Tools Tactics
Updated Cyber Security and Fraud Prevention Tools TacticsUpdated Cyber Security and Fraud Prevention Tools Tactics
Updated Cyber Security and Fraud Prevention Tools Tactics
Ben Graybar
 
Cmp104 lec 7 algorithm and flowcharts
Cmp104 lec 7 algorithm and flowchartsCmp104 lec 7 algorithm and flowcharts
Cmp104 lec 7 algorithm and flowcharts
kapil078
 
Social Media Cyber Security Awareness Briefing
Social Media Cyber Security Awareness BriefingSocial Media Cyber Security Awareness Briefing
Social Media Cyber Security Awareness Briefing
Department of Defense
 
Introduction to Cyber Security
Introduction to Cyber SecurityIntroduction to Cyber Security
Introduction to Cyber Security
Stephen Lahanas
 
Cyber crime and security ppt
Cyber crime and security pptCyber crime and security ppt
Cyber crime and security ppt
Lipsita Behera
 

En vedette (20)

C programming
C programmingC programming
C programming
 
Cyber security and Hacking
Cyber security and HackingCyber security and Hacking
Cyber security and Hacking
 
Recent Trends in Cyber Security
Recent Trends in Cyber SecurityRecent Trends in Cyber Security
Recent Trends in Cyber Security
 
Updated Cyber Security and Fraud Prevention Tools Tactics
Updated Cyber Security and Fraud Prevention Tools TacticsUpdated Cyber Security and Fraud Prevention Tools Tactics
Updated Cyber Security and Fraud Prevention Tools Tactics
 
Cyber security
Cyber securityCyber security
Cyber security
 
The Future of Cyber Security
The Future of Cyber SecurityThe Future of Cyber Security
The Future of Cyber Security
 
7 problem solving with loops
7 problem solving with loops7 problem solving with loops
7 problem solving with loops
 
Cmp104 lec 7 algorithm and flowcharts
Cmp104 lec 7 algorithm and flowchartsCmp104 lec 7 algorithm and flowcharts
Cmp104 lec 7 algorithm and flowcharts
 
General Awareness On Cyber Security
General Awareness On Cyber SecurityGeneral Awareness On Cyber Security
General Awareness On Cyber Security
 
Computer Network, Internet, Computer Security and Cyber Ethics
Computer Network, Internet, Computer Security and Cyber EthicsComputer Network, Internet, Computer Security and Cyber Ethics
Computer Network, Internet, Computer Security and Cyber Ethics
 
Social Media Cyber Security Awareness Briefing
Social Media Cyber Security Awareness BriefingSocial Media Cyber Security Awareness Briefing
Social Media Cyber Security Awareness Briefing
 
Cyber crime and security 1
Cyber crime and security 1Cyber crime and security 1
Cyber crime and security 1
 
Danish Centre for Cyber Security - Thomas Kristmar - CEOs leading recovery in...
Danish Centre for Cyber Security - Thomas Kristmar - CEOs leading recovery in...Danish Centre for Cyber Security - Thomas Kristmar - CEOs leading recovery in...
Danish Centre for Cyber Security - Thomas Kristmar - CEOs leading recovery in...
 
Smart Grid Cyber Security
Smart Grid Cyber SecuritySmart Grid Cyber Security
Smart Grid Cyber Security
 
Introduction to Cyber Security
Introduction to Cyber SecurityIntroduction to Cyber Security
Introduction to Cyber Security
 
Cyber security
Cyber securityCyber security
Cyber security
 
7 cyber security questions for boards
7 cyber security questions for boards7 cyber security questions for boards
7 cyber security questions for boards
 
Cyber security presentation
Cyber security presentationCyber security presentation
Cyber security presentation
 
Cyber crime and security ppt
Cyber crime and security pptCyber crime and security ppt
Cyber crime and security ppt
 
Data structure lecture 1
Data structure   lecture 1Data structure   lecture 1
Data structure lecture 1
 

Similaire à C programming

C basics
C basicsC basics
C basics
MSc CST
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
Vishal Singh
 

Similaire à C programming (20)

C file
C fileC file
C file
 
C programms
C programmsC programms
C programms
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdf
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docx
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Basic C Programming Lab Practice
Basic C Programming Lab PracticeBasic C Programming Lab Practice
Basic C Programming Lab Practice
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
C Programming
C ProgrammingC Programming
C Programming
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
Struct examples
Struct examplesStruct examples
Struct examples
 
C basics
C basicsC basics
C basics
 
C lab
C labC lab
C lab
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
C programming function
C  programming functionC  programming function
C programming function
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 

Plus de Samsil Arefin

Plus de Samsil Arefin (20)

Transmission Control Protocol and User Datagram protocol
Transmission Control Protocol and User Datagram protocolTransmission Control Protocol and User Datagram protocol
Transmission Control Protocol and User Datagram protocol
 
Evolution Phylogenetic
Evolution PhylogeneticEvolution Phylogenetic
Evolution Phylogenetic
 
Evolution Phylogenetic
Evolution PhylogeneticEvolution Phylogenetic
Evolution Phylogenetic
 
Ego net facebook data analysis
Ego net facebook data analysisEgo net facebook data analysis
Ego net facebook data analysis
 
Augmented Reality (AR)
Augmented Reality (AR)Augmented Reality (AR)
Augmented Reality (AR)
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat application
 
Strings in programming tutorial.
Strings  in programming tutorial.Strings  in programming tutorial.
Strings in programming tutorial.
 
Linked list searching deleting inserting
Linked list searching deleting insertingLinked list searching deleting inserting
Linked list searching deleting inserting
 
Number theory
Number theoryNumber theory
Number theory
 
Program to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical orderProgram to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical order
 
Linked list int_data_fdata
Linked list int_data_fdataLinked list int_data_fdata
Linked list int_data_fdata
 
Linked list Output tracing
Linked list Output tracingLinked list Output tracing
Linked list Output tracing
 
Stack
StackStack
Stack
 
Sorting
SortingSorting
Sorting
 
Fundamentals of-electric-circuit
Fundamentals of-electric-circuitFundamentals of-electric-circuit
Fundamentals of-electric-circuit
 
Cyber security
Cyber securityCyber security
Cyber security
 
Structure and union
Structure and unionStructure and union
Structure and union
 
Structure in programming in c or c++ or c# or java
Structure in programming  in c or c++ or c# or javaStructure in programming  in c or c++ or c# or java
Structure in programming in c or c++ or c# or java
 
String
StringString
String
 
String in programming language in c or c++
 String in programming language  in c or c++  String in programming language  in c or c++
String in programming language in c or c++
 

Dernier

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Dernier (20)

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 

C programming

  • 1.
  • 3. Q1. Write a program that will read a string and show each character with one space.  #include<stdio.h>  int main ()  {  char ch[1000];  int i;  printf("ENTER A STRING:n");  gets(ch);  printf("WITH SPACE : n");  for(i=0;ch[i]!='0';i++)  {  printf("%c ",ch[i]);  }  return 0;  }
  • 4. Q2. Write a program that will read a string and show each character with one space in reverse order.  #include<stdio.h>  int main ()  {  char ch[1000];  int i,j;  printf("ENTER A STRING:n");  gets(ch);  printf("REVERS PRINT WITH SPACE : n");  for(i=0;ch[i]!='0';i++);  for(j=i-1;j>=0;j--)  {  printf("%c ",ch[j]);  }  return 0;  }
  • 5. Q3. Write a program that will read a string and show each character in separate line.  #include<stdio.h>  int main ()  {  char ch[1000];  int i;  printf("ENTER A STRING:n");  gets(ch);  printf("EACH CHARACTER IN SEPARATE LINE: n");  for(i=0;ch[i]!='0';i++)  {  printf("%cn",ch[i]);  }  return 0;  }
  • 6. Q4. Write a program that will read a string and show each character and corresponding ASCII value in separate line.  #include<stdio.h>  int main ()  {  char ch[1000];  int i;  printf("ENTER A STRING:n");  gets(ch);  printf("EACH CHARACTER IN SEPARATE LINE WITH CORRESPONDING ASCII VALUE: n");  for(i=0;ch[i]!='0';i++)  {  printf("%ct%dn",ch[i],ch[i]);  }  return 0;  }
  • 7. Q5. Write a program that will read a string and show frequency of every character in this string.  #include<stdio.h>  int main ()  {  char ch[1000];  int i,count[26]={0};  printf("ENTER A STRING:n");  gets(ch);  for(i=0;ch[i]!='0';i++)  {  if(ch[i]>='a'&&ch[i]<='z')  count[ch[i]-'a']++;  }  for(i=0;i<26;i++)  {  if(count[i]!=0)  printf("%c OCCURS %d TIME(S):n",i+'a',count[i]);  }  return 0;  }
  • 8. Q6. Write a program that will read a string and show the length of that string.  #include<stdio.h>  int main ()  {  char ch[1000];  int i;  printf("ENTER A STRING:n");  gets(ch);  for(i=0;ch[i]!='0';i++);  printf("LENGTH OF THE STRING IS : %d",i);  return 0;  }
  • 9. Q7. Write a program that will read a string and show the string in reverse order.  #include<stdio.h>  int main ()  {  char ch[1000];  int i,j;  printf("ENTER A STRING:n");  gets(ch);  printf("REVERS PRINT : n");  for(i=0;ch[i]!='0';i++);  for(j=i-1;j>=0;j--)  {  printf("%c",ch[j]);  }  return 0;  }
  • 10. Q8. Write a program that will read a string and copy this to another string.  #include<stdio.h>  int main ()  {  char ch[100],st[100];  int i,j;  printf("ENTER A STRING:n");  gets(ch);  for(i=0;ch[i]!='0';++i)  {  st[i]=ch[i];  }  st[i]='0';  puts(st);  return 0;  }
  • 11. Q9. Write a program that will read two strings and add second string with first string.  #include<stdio.h>  int main ()  {  char ch[100],st[100];  printf("ENTER FIRST STRING:n");  gets(ch);  printf("ENTER SECOND STRING:n");  gets(st);  strcat(ch,st);  printf("n%s",ch);  return 0;  }
  • 12. Q10. Write a program that will read two strings and compare which one is greater.  #include<stdio.h>  int main ()  {  char ch[1000],st[1000];  int i,j;  printf("ENTER FIRST STRING:n");  gets(ch);  for(i=0;ch[i]!='0';i++);  printf("ENTER SECOND STRING:n");  gets(st);  for(j=0;st[j]!='0';j++);  if(i>j) printf("STRING 1 IS GREATER");  else printf("STRING 2 IS GREATER");  return 0;  }
  • 13. Q11. Write a program that will read a string and convert all lowercase letter to uppercase and all uppercase letter to lowercase.  #include<stdio.h>  int main ()  {  int c;  char ch,s[1000];  printf("ENTER A STRINGn");  gets(s);  for(c=0;s[c]!='0';c++)  {  ch=s[c];  if(ch >= 'A' && ch <= 'Z')  s[c]= s[c]+32;  else if(ch >= 'a' && ch <= 'z')  s[c]= s[c]-32;  }  printf("%sn",s);  return 0;  }
  • 15. Q1. Write a function that gets two integers and returns sum.  #include<stdio.h>  int sum(int a, int b)  {  int result;  result=a+b;  return result;  }  int main ()  {  int x,y,res;  printf("ENTER TWO NUMBERS:n");  scanf("%d %d",&x,&y);  res=sum(x,y);  printf("SUM OF %d AND %d IS %d",x,y,res);  return 0;  }
  • 16. Q2. Write a function that gets two integers and returns division.  #include<stdio.h>  int sum(int a, int b)  {  int result;  result=a+b;  return result;  }  int main ()  {  int x,y,res;  printf("ENTER TWO NUMBERS:n");  scanf("%d %d",&x,&y);  res=sum(x,y);  printf("SUM OF %d AND %d IS %d",x,y,res);  return 0;  }
  • 17. Q3. Write a function that gets length and width of a rectangle and returns area  #include<stdio.h>  int result;  int mul(int a, int b)  {   result=a*b;  return result;  }  int main ()  {  int x,y;  printf("ENTER LENGTH OF THE RECTANGLE:n");  scanf("%d",&x);  printf("ENTER HIGHT OF THE RECTANGLE:n");  scanf("%d",&y);  mul(x,y);  printf("AREA OF THE RECTANGLE IS %d SQUARE UNIT",result);  return 0;  }
  • 18. Q4. Write a function that gets radius of a circle and returns area.  #include<stdio.h>    void ara(float x)  {  float result;  float pi=3.1416;  result=pi*x*x;  printf("AREA OF THE CIRCLE IS %.3f SQUARE UNIT",result);  }  int main ()  {  float r;  printf("ENTER THE RADIOUS OF THE CIRCLE :n");  scanf("%f",&r);  ara(r);   return 0;  }
  • 19. Q5. Write a function that gets any positive integer and returns its factorial.  #include<stdio.h>   int fac(int x)  {  int i,j=1;  for (i=1;i<=x;i++)  {   j=j*i;   }  return j;  }  int main ()  { int y,z;  printf("ENTER A NUMBERn");  scanf("%d",&y);  if(y>=0)  {  z=fac(y);  printf("FACTORIAL OF %d IS %d",y,z);  }  else printf("Number is negative");  return 0;  }
  • 20. Q6. Write a function that gets any positive integer and returns its reverse  #include<stdio.h>  int revrs(int num)  {  int reminder,reverse=0,res;  while(num>0)  {  reminder = num%10;  num = num/10;  reverse = reverse*10+reminder;   }  return reverse;  }  int main()  {  int a,res;  printf("Enter a positive integer number: ");  scanf("%d",&a);  if(a<0)  {  printf("Number is negativen");  } else  {  res = revrs(a);  printf("%d",res);  }  return 0;  }
  • 21. Q7. Write a function that gets two positive integers and returns LCM (Least Common Multiple).  #include<stdio.h>  void lcm(int x,int y)  {  int i=1;   while(i>0)  {  if(i%x==0 && i%y==0)  {  printf("THE LCM OF %d AND %d IS %d",x,y,i);  break;   }i++;  }  }  int main ()  {  int p,q;  scanf("%d %d",&p,&q);  lcm(p,q);  }
  • 22. Q8. Write a function that gets two positive integers and returns nCr.  #include<stdio.h>  int fac(int x)  {  int i,j=1;  for (i=1;i<=x;i++)  {   j=j*i;   }  return j;  }   int main()  {  int n,m,o,p,q,r,s;  printf("ENTER n:n");  scanf("%d",&n);  printf("ENTER r:n");  scanf("%d",&r);  o=fac(r);  m=fac(n);  p=(n-r);  q=fac(p);  if(n>=0 && r >=0 && n>=r){  s=m/(q*o);  printf("%dC%d = %d",n,r,s);  }  else printf("MATH ERROR");  }
  • 23. Q9. Write a function that gets any positive integer and determine prime or not prime.  #include<stdio.h>  int prime=0;  void pri(int x)  {  int i;  for(i=2;i<=x/2;i++)  {  if(x%i==0)  {  prime=1;  break;  }  }  if(prime==0) printf("%d IS A PRIME NUMBER",x);  else printf("%d IS NOT A PRIME NUMBER",x);    }  int main()  {  int n;   scanf("%d",&n);  pri(n);   }