SlideShare a Scribd company logo
1 of 7
1
WrittenbyHazrat Bilal
Studentat Abdul Wali KhanUniversity
Contact No:+923209600215
1) Write a code for the followingoutput.
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Code:
#include <stdio.h>
intmain()
{
inti,j,k=4,c;
for(i=1;i<=5;i++)
{
for(c=1;c<=k;c++)
printf("");
for(j=1;j<=i;j++)
printf("%d",i);
printf("n");
k--;
}
}
Output:
2
WrittenbyHazrat Bilal
Studentat Abdul Wali KhanUniversity
Contact No:+923209600215
2) Write a code for the followingoutput.
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Code:
#include <stdio.h>
intmain()
{
inti,j,k=4,c;
for(i=1;i<=5;i++)
{
for(c=1;c<=k;c++)
printf("");
for(j=1;j<=i;j++)
printf("%d",j);
printf("n");
k--;
}
}
Output:
3) Write a code for the followingOutput:
1
2 3
4 5 6
7 8 9 10
Code: #include <stdio.h>
intmain()
{
int a,b,n=6;
for(a=1; a<=10; a++)
{
if(a==1|| a==2 ||a==4 || a==7)
{
3
WrittenbyHazrat Bilal
Studentat Abdul Wali KhanUniversity
Contact No:+923209600215
printf("n");
for(b=1;b<=n; b++)
printf("");
n=n-2;
}
printf("%4d",a);
}
}
Output:
4) Write a code for the followingoutput.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Code:
#include<stdio.h>
#include<conio.h>
voidmain()
{
intlines,n=1,spaces,tabs=8, x,y=1;
for(lines=1;lines<=5;lines++)
{
for(spaces=1;spaces<=tabs;spaces++)
printf("");
printf("%4d",n);
if(lines>=3)
{
for(x=1;x<=y;x++)
{
if(x==2&&y==3)
printf("%4d",lines+1);
else
printf("%4d",lines-1);
}
y++;
4
WrittenbyHazrat Bilal
Studentat Abdul Wali KhanUniversity
Contact No:+923209600215
}
if(lines>=2)
printf("%4d",n);
tabs=tabs-2;
printf("n");
}
getch();
}
Output:
5) Write a code for the followingoutput:
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
Code:
#include <stdio.h>
main()
{
inta,b,n=8;
for(a=1;a<=5;a++)
{
for(b=1;b<=n;b++)
{
printf("");
}
n=n-2;
if(a==1)
printf("%d",a);
if(a==2)
printf("%d%d%d",a,a+1,a);
if(a==3)
printf("%d%d%d%d%d",a,a+1,a+2,a+1,a);
if(a==4)
printf("%d%d%d%d%d%d%d",a,a+1,a+2,a+3,a+2,a+1,a);
5
WrittenbyHazrat Bilal
Studentat Abdul Wali KhanUniversity
Contact No:+923209600215
if(a==5)
printf("%d%d%d%d%d%d %d %d%d",a,a+1,a+2,a+3,a+4,a+3,a+2,a+1,a);
printf("n");
}
}
Output:
6) Write a code for the followingOutput:
A
ABC
ABCDE
ABCDEFG
ABCDEFGHI
Code:
#include <stdio.h>
intmain()
{
inta=65,b,c,d=4;
while(a<=73)
{
for(b=1;b<=d;b++)
printf("");
for(c=65;c<=a;c++)
{
printf("%c",c);
}
d=d-1;
printf("n");
a=a+2;
}
}
6
WrittenbyHazrat Bilal
Studentat Abdul Wali KhanUniversity
Contact No:+923209600215
Output:
7)Write a code for the followingOutput:
*
* *
* * *
* * * *
* * * * *
Code:
#include <stdio.h>
intmain()
{
intnor,row,sp,st;
printf("Enterthe numberof rows:");
scanf("%d",&nor);
for(row=1;row<=nor;row++)
{
for(sp=nor-row;sp>=1;sp--)
printf("");
for(st=1;st<=row;st++)
printf("*");
printf("n");
}
}
Output:
7
WrittenbyHazrat Bilal
Studentat Abdul Wali KhanUniversity
Contact No:+923209600215
7) Write a code for the followingoutput:
Code:
#include <stdio.h>
intmain()
{
inta,b,c,d;
for(a=1;a<=5;a++)
{
for(b=1;b<=a;b++)
printf("%d",b);
printf("n");
}
for(c=4;c>=1;c--)
{
for(d=1;d<=c;d++)
printf("%d",d);
printf("n");
}
}
Output:

More Related Content

What's hot

Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionHazrat Bilal
 
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 ANSWERSKavyaSharma65
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in cBUBT
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C BUBT
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CBUBT
 
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1rohit kumar
 
LET US C (5th EDITION) CHAPTER 1 ANSWERS
LET US C (5th EDITION) CHAPTER 1 ANSWERSLET US C (5th EDITION) CHAPTER 1 ANSWERS
LET US C (5th EDITION) CHAPTER 1 ANSWERSKavyaSharma65
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Aman Deep
 
C programs
C programsC programs
C programsMinu S
 
Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
 
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 numberMainak Sasmal
 
Exercices pascal tous les chapitres
Exercices pascal tous les chapitresExercices pascal tous les chapitres
Exercices pascal tous les chapitresborhen boukthir
 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementSreedhar Chowdam
 
Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classesasadsardar
 
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek StavisiMasters
 
Types of function call
Types of function callTypes of function call
Types of function callArijitDhali
 

What's hot (20)

Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solution
 
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
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in c
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in C
 
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
 
bac info : série récursivité
bac info : série récursivitébac info : série récursivité
bac info : série récursivité
 
LET US C (5th EDITION) CHAPTER 1 ANSWERS
LET US C (5th EDITION) CHAPTER 1 ANSWERSLET US C (5th EDITION) CHAPTER 1 ANSWERS
LET US C (5th EDITION) CHAPTER 1 ANSWERS
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 
C programs
C programsC programs
C programs
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
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
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Exercices pascal tous les chapitres
Exercices pascal tous les chapitresExercices pascal tous les chapitres
Exercices pascal tous les chapitres
 
C Programming
C ProgrammingC Programming
C Programming
 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory management
 
Ansi c
Ansi cAnsi c
Ansi c
 
Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classes
 
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
 
Types of function call
Types of function callTypes of function call
Types of function call
 

Similar to Printing different pyramid patterns of numbers,alphabets and stars using C.

Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Jaydip JK
 
Fuzail_File_C.docx
Fuzail_File_C.docxFuzail_File_C.docx
Fuzail_File_C.docxSyedFuzail14
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbTUSHARGAURAV11
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbTUSHARGAURAV11
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-yearAMIT SINGH
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentalsZaibi Gondal
 
Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Salar Delavar Qashqai
 
Lab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practiceLab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practiceranaibrahim453
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
Assignement of c++
Assignement of c++Assignement of c++
Assignement of c++Syed Umair
 
Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structureHarithaRanasinghe
 
Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Syed Umair
 

Similar to Printing different pyramid patterns of numbers,alphabets and stars using C. (20)

Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
 
pattern-printing-in-c.pdf
pattern-printing-in-c.pdfpattern-printing-in-c.pdf
pattern-printing-in-c.pdf
 
Fuzail_File_C.docx
Fuzail_File_C.docxFuzail_File_C.docx
Fuzail_File_C.docx
 
Automata fix.pdf
Automata fix.pdfAutomata fix.pdf
Automata fix.pdf
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
 
Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...
 
Lab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practiceLab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practice
 
C Programming
C ProgrammingC Programming
C Programming
 
Technical quiz 5#.pptx
Technical quiz 5#.pptxTechnical quiz 5#.pptx
Technical quiz 5#.pptx
 
Qno 1 (f)
Qno 1 (f)Qno 1 (f)
Qno 1 (f)
 
C-LOOP-Session-2.pptx
C-LOOP-Session-2.pptxC-LOOP-Session-2.pptx
C-LOOP-Session-2.pptx
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Assignement of c++
Assignement of c++Assignement of c++
Assignement of c++
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
 
Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structure
 
Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)
 

Recently uploaded

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 

Recently uploaded (20)

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 

Printing different pyramid patterns of numbers,alphabets and stars using C.

  • 1. 1 WrittenbyHazrat Bilal Studentat Abdul Wali KhanUniversity Contact No:+923209600215 1) Write a code for the followingoutput. 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 Code: #include <stdio.h> intmain() { inti,j,k=4,c; for(i=1;i<=5;i++) { for(c=1;c<=k;c++) printf(""); for(j=1;j<=i;j++) printf("%d",i); printf("n"); k--; } } Output:
  • 2. 2 WrittenbyHazrat Bilal Studentat Abdul Wali KhanUniversity Contact No:+923209600215 2) Write a code for the followingoutput. 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 Code: #include <stdio.h> intmain() { inti,j,k=4,c; for(i=1;i<=5;i++) { for(c=1;c<=k;c++) printf(""); for(j=1;j<=i;j++) printf("%d",j); printf("n"); k--; } } Output: 3) Write a code for the followingOutput: 1 2 3 4 5 6 7 8 9 10 Code: #include <stdio.h> intmain() { int a,b,n=6; for(a=1; a<=10; a++) { if(a==1|| a==2 ||a==4 || a==7) {
  • 3. 3 WrittenbyHazrat Bilal Studentat Abdul Wali KhanUniversity Contact No:+923209600215 printf("n"); for(b=1;b<=n; b++) printf(""); n=n-2; } printf("%4d",a); } } Output: 4) Write a code for the followingoutput. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 Code: #include<stdio.h> #include<conio.h> voidmain() { intlines,n=1,spaces,tabs=8, x,y=1; for(lines=1;lines<=5;lines++) { for(spaces=1;spaces<=tabs;spaces++) printf(""); printf("%4d",n); if(lines>=3) { for(x=1;x<=y;x++) { if(x==2&&y==3) printf("%4d",lines+1); else printf("%4d",lines-1); } y++;
  • 4. 4 WrittenbyHazrat Bilal Studentat Abdul Wali KhanUniversity Contact No:+923209600215 } if(lines>=2) printf("%4d",n); tabs=tabs-2; printf("n"); } getch(); } Output: 5) Write a code for the followingoutput: 1 2 3 2 3 4 5 4 3 4 5 6 7 6 5 4 5 6 7 8 9 8 7 6 5 Code: #include <stdio.h> main() { inta,b,n=8; for(a=1;a<=5;a++) { for(b=1;b<=n;b++) { printf(""); } n=n-2; if(a==1) printf("%d",a); if(a==2) printf("%d%d%d",a,a+1,a); if(a==3) printf("%d%d%d%d%d",a,a+1,a+2,a+1,a); if(a==4) printf("%d%d%d%d%d%d%d",a,a+1,a+2,a+3,a+2,a+1,a);
  • 5. 5 WrittenbyHazrat Bilal Studentat Abdul Wali KhanUniversity Contact No:+923209600215 if(a==5) printf("%d%d%d%d%d%d %d %d%d",a,a+1,a+2,a+3,a+4,a+3,a+2,a+1,a); printf("n"); } } Output: 6) Write a code for the followingOutput: A ABC ABCDE ABCDEFG ABCDEFGHI Code: #include <stdio.h> intmain() { inta=65,b,c,d=4; while(a<=73) { for(b=1;b<=d;b++) printf(""); for(c=65;c<=a;c++) { printf("%c",c); } d=d-1; printf("n"); a=a+2; } }
  • 6. 6 WrittenbyHazrat Bilal Studentat Abdul Wali KhanUniversity Contact No:+923209600215 Output: 7)Write a code for the followingOutput: * * * * * * * * * * * * * * * Code: #include <stdio.h> intmain() { intnor,row,sp,st; printf("Enterthe numberof rows:"); scanf("%d",&nor); for(row=1;row<=nor;row++) { for(sp=nor-row;sp>=1;sp--) printf(""); for(st=1;st<=row;st++) printf("*"); printf("n"); } } Output:
  • 7. 7 WrittenbyHazrat Bilal Studentat Abdul Wali KhanUniversity Contact No:+923209600215 7) Write a code for the followingoutput: Code: #include <stdio.h> intmain() { inta,b,c,d; for(a=1;a<=5;a++) { for(b=1;b<=a;b++) printf("%d",b); printf("n"); } for(c=4;c>=1;c--) { for(d=1;d<=c;d++) printf("%d",d); printf("n"); } } Output: