SlideShare a Scribd company logo
1 of 26
LOGIC DEVELOPMENT
CONTROL FLOW ANALYSIS & C BASICS
1.FIND THE PATTERN!
• n = input (“Enter a positive integer”)
• while n > 0
• c = n
• while c > 0
• print n
• c = c – 1
• end
• n = n - 1
• print newline
• end
Ans : 1
• Input : n=5;
• Output:
• 55555
• 4444
• 333
• 22
• 1
2.FIND THE OUTPUT!
• int main() {
• int a[5] = {5, 1, 15, 20, 25};
• int i, j, m;
• i = ++a[1];
• j = a[1]++;
• m = a[i++];
• printf("%d, %d, %d", i, j, m);
• return 0;
• }
Ans : 2
• OUTPUT : 2,2,3
• Solution:
• A[1]=1;
• A[1]=2;
• i=2;
• J=2
• A[1]=3;
• i=3
• M=A[3]=15
3.FIND THE OUTPUT!
• int main() {
• int i = 1;
• switch(i) {
• printf("Hellon");
• case 1: printf("Hin");
• break;
• case 2: printf("nByen");
• break;
• }
• return 0;
• }
Ans : 3
• OUTPUT: Hi
• Solution: Switch uses concept of label;
4.FIND THE OUTPUT!
• int main() {
• char str[]="C-program";
• int a = 5;
• printf(a >10?"Psn":"%sn", str);
• return 0;
• }
Ans : 4
• OUTPUT : C-program
5.FIND THE OUTPUT!
What will be the output of the program (sample.c) given below if it is
executed from the command line?
cmd> sample monday tuesday wednesday thursday
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[]) {
while(--argc>0)
printf("%s", *++argv);
return 0;
}
ANS : 5
• OUTPUT :
6. What does fp points to?
• int main() {
• FILE *fp;
• fp=fopen("trial", "r");
• return 0;
• }
ANS : 6
7.FIND THE OUTPUT!
• int main() {
• char str[] = "peace";
• char *s = str;
• printf("%sn", s++ +3);
• return 0;
• }
ANS : 7
• OUTPUT : ce
8.FIND THE OUTPUT!
• int main() {
• int *p;
• p = (int *)malloc(20);
• printf("%dn", sizeof(p));
• free(p);
• return 0;
• }
ANS : 8
• OUTPUT : 4
9.FIND THE OUTPUT!
What will be the output of the program (sample.c) given below if it is
executed from the command line?
cmd> sample friday tuesday sunday
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[]) {
printf("%c", *++argv[2] );
return 0;
}
ANS: 9
• OUPUT : u
• SOLUTION: argv[2]= Tuesday
• ++ argv[2] =uesday;
• %c of ++argv[2] = u
10.FIND THE OUTPUT!
• int main() {
• short int i = 0;
• for(i<=5 && i>=-1; ++i; i>0)
• printf("%u,", i);
• return 0;
• }
11.FIND THE OUTPUT!
• int main() {
• int y=128;
• const int x=y;
• printf("%dn", x);
• return 0;
• }
ANS : 11
• OUTPUT : 128
12.FIND THE OUTPUT!
• int main() {
• struct emp {
• char n[20];
• int age;
• };
• struct emp e1 = {"Dravid", 23};
• struct emp e2 = e1;
• if(e1 == e2)
• printf("The structure are equal");
• return 0;
• }
ANS :12
• OUTPUTS NOTHING;
• Error occurs at run time..! Struct data structures cannot be
compared using ‘==‘ Operator
13.FIND THE OUTPUT!
• int main() {
• printf(5+"IndiaBIXn");
• return 0;
• }
ANS : 13
• OUTPUT : BIX

More Related Content

What's hot (17)

Runge kutta C programme
Runge kutta C programmeRunge kutta C programme
Runge kutta C programme
 
Program presentation
Program presentationProgram presentation
Program presentation
 
C program to check leap year
C program to check leap year C program to check leap year
C program to check leap year
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Method C# - Lec8 (Workshop on C# Programming: Learn to Build)
Method C# - Lec8 (Workshop on C# Programming: Learn to Build)Method C# - Lec8 (Workshop on C# Programming: Learn to Build)
Method C# - Lec8 (Workshop on C# Programming: Learn to Build)
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
Array list
Array listArray list
Array list
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
Include
IncludeInclude
Include
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY Mazedur
 
C
CC
C
 
C & Python Introduction
C & Python IntroductionC & Python Introduction
C & Python Introduction
 
Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)
 
Aggregate
AggregateAggregate
Aggregate
 
1 (1)
1 (1)1 (1)
1 (1)
 

Viewers also liked

Dicas de Planejamento & Estratégia de Comunicação e Marketing, por Rô Villa...
Dicas de Planejamento &  Estratégia de Comunicação e Marketing, por Rô Villa...Dicas de Planejamento &  Estratégia de Comunicação e Marketing, por Rô Villa...
Dicas de Planejamento & Estratégia de Comunicação e Marketing, por Rô Villa...Ro Villa Real
 
Advertisment Fallacies in the United States
Advertisment Fallacies in the United StatesAdvertisment Fallacies in the United States
Advertisment Fallacies in the United StatesJon Dav
 
Makalah epidemiologi kel5
Makalah epidemiologi kel5Makalah epidemiologi kel5
Makalah epidemiologi kel5azizahrahmasari
 
Eleições 2016 - Gestão e Inteligência no Marketing Político e Eleitoral
Eleições 2016 - Gestão e Inteligência no Marketing Político e EleitoralEleições 2016 - Gestão e Inteligência no Marketing Político e Eleitoral
Eleições 2016 - Gestão e Inteligência no Marketing Político e EleitoralLéia Dornelas
 
The Power of Self Belief
The Power of Self BeliefThe Power of Self Belief
The Power of Self BeliefJon Dav
 
Major Genetically Modified Crops
Major Genetically Modified CropsMajor Genetically Modified Crops
Major Genetically Modified Cropssoccer4kk
 
โครงการระบบป้องกันน้ำท่วมรังสิต
โครงการระบบป้องกันน้ำท่วมรังสิตโครงการระบบป้องกันน้ำท่วมรังสิต
โครงการระบบป้องกันน้ำท่วมรังสิตrangsitengineer
 

Viewers also liked (14)

MODULO 4
MODULO 4MODULO 4
MODULO 4
 
Буктрейлер
БуктрейлерБуктрейлер
Буктрейлер
 
MODULO 2
MODULO 2MODULO 2
MODULO 2
 
Pursueasia global connexio 1
Pursueasia global connexio 1Pursueasia global connexio 1
Pursueasia global connexio 1
 
Dicas de Planejamento & Estratégia de Comunicação e Marketing, por Rô Villa...
Dicas de Planejamento &  Estratégia de Comunicação e Marketing, por Rô Villa...Dicas de Planejamento &  Estratégia de Comunicação e Marketing, por Rô Villa...
Dicas de Planejamento & Estratégia de Comunicação e Marketing, por Rô Villa...
 
Advertisment Fallacies in the United States
Advertisment Fallacies in the United StatesAdvertisment Fallacies in the United States
Advertisment Fallacies in the United States
 
1
11
1
 
SQL
SQLSQL
SQL
 
Makalah epidemiologi kel5
Makalah epidemiologi kel5Makalah epidemiologi kel5
Makalah epidemiologi kel5
 
Eleições 2016 - Gestão e Inteligência no Marketing Político e Eleitoral
Eleições 2016 - Gestão e Inteligência no Marketing Político e EleitoralEleições 2016 - Gestão e Inteligência no Marketing Político e Eleitoral
Eleições 2016 - Gestão e Inteligência no Marketing Político e Eleitoral
 
Tomato-based products
Tomato-based productsTomato-based products
Tomato-based products
 
The Power of Self Belief
The Power of Self BeliefThe Power of Self Belief
The Power of Self Belief
 
Major Genetically Modified Crops
Major Genetically Modified CropsMajor Genetically Modified Crops
Major Genetically Modified Crops
 
โครงการระบบป้องกันน้ำท่วมรังสิต
โครงการระบบป้องกันน้ำท่วมรังสิตโครงการระบบป้องกันน้ำท่วมรังสิต
โครงการระบบป้องกันน้ำท่วมรังสิต
 

Similar to Logic development

Similar to Logic development (20)

UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
 
Mcs011 solved assignment by divya singh
Mcs011 solved assignment by divya singhMcs011 solved assignment by divya singh
Mcs011 solved assignment by divya singh
 
Pointer example
Pointer examplePointer example
Pointer example
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
pointers 1
pointers 1pointers 1
pointers 1
 
Cse115 lecture08repetitionstructures part02
Cse115 lecture08repetitionstructures part02Cse115 lecture08repetitionstructures part02
Cse115 lecture08repetitionstructures part02
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
C tech questions
C tech questionsC tech questions
C tech questions
 
C programs
C programsC programs
C programs
 
Hargun
HargunHargun
Hargun
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
12 lec 12 loop
12 lec 12 loop 12 lec 12 loop
12 lec 12 loop
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Vcs16
Vcs16Vcs16
Vcs16
 
PRACTICAL COMPUTING
PRACTICAL COMPUTINGPRACTICAL COMPUTING
PRACTICAL COMPUTING
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Simple c program
Simple c programSimple c program
Simple c program
 
programs on arrays.pdf
programs on arrays.pdfprograms on arrays.pdf
programs on arrays.pdf
 
Tech-1.pptx
Tech-1.pptxTech-1.pptx
Tech-1.pptx
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
 

Recently uploaded

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 

Recently uploaded (20)

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

Logic development

  • 1. LOGIC DEVELOPMENT CONTROL FLOW ANALYSIS & C BASICS
  • 2. 1.FIND THE PATTERN! • n = input (“Enter a positive integer”) • while n > 0 • c = n • while c > 0 • print n • c = c – 1 • end • n = n - 1 • print newline • end
  • 3. Ans : 1 • Input : n=5; • Output: • 55555 • 4444 • 333 • 22 • 1
  • 4. 2.FIND THE OUTPUT! • int main() { • int a[5] = {5, 1, 15, 20, 25}; • int i, j, m; • i = ++a[1]; • j = a[1]++; • m = a[i++]; • printf("%d, %d, %d", i, j, m); • return 0; • }
  • 5. Ans : 2 • OUTPUT : 2,2,3 • Solution: • A[1]=1; • A[1]=2; • i=2; • J=2 • A[1]=3; • i=3 • M=A[3]=15
  • 6. 3.FIND THE OUTPUT! • int main() { • int i = 1; • switch(i) { • printf("Hellon"); • case 1: printf("Hin"); • break; • case 2: printf("nByen"); • break; • } • return 0; • }
  • 7. Ans : 3 • OUTPUT: Hi • Solution: Switch uses concept of label;
  • 8. 4.FIND THE OUTPUT! • int main() { • char str[]="C-program"; • int a = 5; • printf(a >10?"Psn":"%sn", str); • return 0; • }
  • 9. Ans : 4 • OUTPUT : C-program
  • 10. 5.FIND THE OUTPUT! What will be the output of the program (sample.c) given below if it is executed from the command line? cmd> sample monday tuesday wednesday thursday /* sample.c */ #include<stdio.h> int main(int argc, char *argv[]) { while(--argc>0) printf("%s", *++argv); return 0; }
  • 11. ANS : 5 • OUTPUT :
  • 12. 6. What does fp points to? • int main() { • FILE *fp; • fp=fopen("trial", "r"); • return 0; • }
  • 14. 7.FIND THE OUTPUT! • int main() { • char str[] = "peace"; • char *s = str; • printf("%sn", s++ +3); • return 0; • }
  • 15. ANS : 7 • OUTPUT : ce
  • 16. 8.FIND THE OUTPUT! • int main() { • int *p; • p = (int *)malloc(20); • printf("%dn", sizeof(p)); • free(p); • return 0; • }
  • 17. ANS : 8 • OUTPUT : 4
  • 18. 9.FIND THE OUTPUT! What will be the output of the program (sample.c) given below if it is executed from the command line? cmd> sample friday tuesday sunday /* sample.c */ #include<stdio.h> int main(int argc, char *argv[]) { printf("%c", *++argv[2] ); return 0; }
  • 19. ANS: 9 • OUPUT : u • SOLUTION: argv[2]= Tuesday • ++ argv[2] =uesday; • %c of ++argv[2] = u
  • 20. 10.FIND THE OUTPUT! • int main() { • short int i = 0; • for(i<=5 && i>=-1; ++i; i>0) • printf("%u,", i); • return 0; • }
  • 21. 11.FIND THE OUTPUT! • int main() { • int y=128; • const int x=y; • printf("%dn", x); • return 0; • }
  • 22. ANS : 11 • OUTPUT : 128
  • 23. 12.FIND THE OUTPUT! • int main() { • struct emp { • char n[20]; • int age; • }; • struct emp e1 = {"Dravid", 23}; • struct emp e2 = e1; • if(e1 == e2) • printf("The structure are equal"); • return 0; • }
  • 24. ANS :12 • OUTPUTS NOTHING; • Error occurs at run time..! Struct data structures cannot be compared using ‘==‘ Operator
  • 25. 13.FIND THE OUTPUT! • int main() { • printf(5+"IndiaBIXn"); • return 0; • }
  • 26. ANS : 13 • OUTPUT : BIX

Editor's Notes

  1. Hello hi; Hello bye; Hi; bye;
  2. Ce str[0+3]
  3. 1,2,3,4,5,6
  4. 128