0% found this document useful (0 votes)
16 views2 pages

01 CS12Worksheet1 2012

The document contains 6 code snippets labeled A through F. Each snippet is followed by an "OUTPUT" section that is blank. The code snippets demonstrate various C++ programming concepts like loops, operators, functions, constants, and input/output. The purpose is to have someone run each code snippet and fill in the corresponding "OUTPUT" section with the results. This will help test their understanding of C++ syntax, logic, and output.

Uploaded by

Lipika Kanojia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

01 CS12Worksheet1 2012

The document contains 6 code snippets labeled A through F. Each snippet is followed by an "OUTPUT" section that is blank. The code snippets demonstrate various C++ programming concepts like loops, operators, functions, constants, and input/output. The purpose is to have someone run each code snippet and fill in the corresponding "OUTPUT" section with the results. This will help test their understanding of C++ syntax, logic, and output.

Uploaded by

Lipika Kanojia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Delhi Public School, R.K.

Puram, New Delhi

Computer Science

Find the output of the following C++ Source Code:

SOURCE CODE
#include <iostream.h>

OUTPUT

void main()
{
int A=99,B=9;
A++;
cout<<A<<endl;
++B;
cout<<B<<endl;
A+=B++;
cout<<A<<" & "<<B<<endl;
B+=++A;
cout<<A<<" & "<<B<<endl;
cout<<A+B<<"#"<<A++<<"#"
<<++B<<endl;
cout<<2*B<<"*"<<++A;
cout<<2*A<<"*"<<B++<<endl;
}

SOURCE CODE
#include <iostream.h>
#include <ctype.h>
void main()
{
char Text[]="MinD32oN";
//All Alphabets except 3 and 2

OUTPUT

for (int I=0;Text[I]!='\0';I++)


if (I%2==0)
if (isdigit(Text[I]))
Text[I]=Text[I]+2;
else
Text[I]='@';
else
if (isupper(Text[I]))
Text[I]=tolower(Text[I]);
else
Text[I]=Text[I]+1;
cout<<Text<<endl;
}

SOURCE CODE
#include <iostream.h>

OUTPUT

#define MAX(A,B) A>B


void main()
{
int P=100,Q=150;
(P>Q)?cout<<2*P:cout<<3*Q;
cout<<" Miles"<<endl;
int Result;
Result=(MAX(P,Q))?P-Q:Q-P;
cout<<Result<<endl;
}

C++ Review Worksheet 1

#1/2
[REF:DPSR/COMP12/2012-2013/01]

Delhi Public School, R.K.Puram, New Delhi

SOURCE CODE
#include <iostream.h>
void main()
{
int N=66,M;
char CH1='a',CH2;
M=CH1;
CH2=N;
cout<<CH1<<" & "<<CH2<<endl;
cout<<N<<" OR "<<M<<endl;

Computer Science
OUTPUT

CH1++;
CH2+=2;
cout<<(int)CH1<<"$"
<<(int)CH2<<endl;
}

SOURCE CODE
#include <iostream.h>
void main()
{
int N=10,L=20;
float X,Y;
cout<<1/2<<" and "<<"1/2"<<endl;
cout<<N/L<<endl;

OUTPUT

X=N/L;
cout<<X<<endl;
X=(float)N/L;
cout<<X<<endl;
X=N/(float)L;
cout<<X<<endl;
X=(float)(N/L);
cout<<X<<endl;
cout<<(float)N/L<<endl;
Y=N;
X=Y/L;
cout<<X<<endl;
N=Y/L;
cout<<N<<endl;
}

SOURCE CODE
#include <iostream.h>
const int MAX=5;
void main()
{
int P=1;
for (int I=40;I>=MAX;I-=5)
{
P=(P+1)%3;
cout<<I<<:<<P<<endl;
}
cout<<Final I:<<I<<endl;
cout<<Final P:<<P<<endl;
}

OUTPUT

C++ Review Worksheet 1

#2/2
[REF:DPSR/COMP12/2012-2013/01]

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy