3.1 dev c++
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int a,b;
cout<<"nilai a= ";
cin>>a;
cout<<"nilai b= ";
cin>>b;
if(a>b)
cout<<" angka terbesar adalah = "<<A;
else
cout<<" angka terbesar adalah = "<<B;
return 0;
}
3.1 bentuk flowchat
3.2 dev c++
using namespace std;
int main(int argc, char** argv) {
int x,y,z;
cout<<"masukkan niai x= ";
cin>>x;
cout<<"masukkan niai y= ";
cin>>y;
cout<<"masukkan niai z= ";
cin>>z;
if(x>y && x>z)
cout<<" angka terbesar adalah = "<<x;
else if (y>x && y>z)
cout<<" angka terbesar adalah = "<<y;
else
cout<<" angka terbesar adalah = "<<z;
return 0;
}
3.2 flowchat
3.3 dev c++
#include <iostream>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int a,b,c;
long disk;
float x1,x2;
cout<<"Koefisien pangkat 2 : ";
cin>>a;
cout<<"Koefisien pangkat 1 : ";
cin>>b;
cout<<"Koefisien pangkat 0 : ";
cin>>c;
if(a==0){
cout<<"Bukan persamaan kuadrat \n";
cout<<"Harga akar = "<<-c/b;
}
else {
disk= b*b-4*a*c;
if(disk>0){
x1=-b+sqrt(disk)/(2*a);
x2=-b-sqrt(disk)/(2*a);
cout<<"diskriminan = "<<disk<<endl;
cout<<"x1 = "<<x1<<endl;
cout<<"x2 = "<<x2<<endl;
}
else if(disk==0){
x1=-b/(2*a);
x2=x1;
cout<<"diskriminan = 0 \n";
cout<<"x1 = "<<x1<<endl;
cout<<"x2 = "<<x2<<endl;
}
else
cout<<"Akar imajiner";
}
return 0;
}
3.3 flowchat

3.4 dev c++
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
int a;
cout<<"Masukan Angka : ";
cin>>a;
if(a>=81 && a<=100)
cout<<"Nilai Huruf = A";
else if(a>=61 && a<=80)
cout<<"Nilai Huruf = B";
else if(a>=41 && a<=60)
cout<<"Nilai Huruf = C";
else if(a>=21 && a<=40)
cout<<"Nilai Huruf = D";
else if(a>=0 && a<=20)
cout<<"Nilai Huruf = E";
else
cout<<"Eror";
return 0;
}
using namespace std;
int main(int argc, char** argv) {
int a;
cout<<"Masukan Angka : ";
cin>>a;
if(a>=81 && a<=100)
cout<<"Nilai Huruf = A";
else if(a>=61 && a<=80)
cout<<"Nilai Huruf = B";
else if(a>=41 && a<=60)
cout<<"Nilai Huruf = C";
else if(a>=21 && a<=40)
cout<<"Nilai Huruf = D";
else if(a>=0 && a<=20)
cout<<"Nilai Huruf = E";
else
cout<<"Eror";
return 0;
}
3.4 flowchat
3.5 dev c++
#include <iostream>
int main(int argc, char *argv[]) {
int A;
cout<<"Masukan angka : ";cin>>A;
switch(A){
case 1:{
cout<<"Senin ";
break;
}
case 2:{
cout<<"Selasa";
break;
}
case 3 :{
cout<<"Rabu";
break;
}
case 4 :{
cout<<"Kamis";
break;
}
case 5:{
cout<<"Jum'at";
break;
}
case 6:{
cout<<"Sabtu";
break;
}
case 7: {
cout<<"Minggu";
break; }
}
return 0;
}
int main(int argc, char *argv[]) {
int A;
cout<<"Masukan angka : ";cin>>A;
switch(A){
case 1:{
cout<<"Senin ";
break;
}
case 2:{
cout<<"Selasa";
break;
}
case 3 :{
cout<<"Rabu";
break;
}
case 4 :{
cout<<"Kamis";
break;
}
case 5:{
cout<<"Jum'at";
break;
}
case 6:{
cout<<"Sabtu";
break;
}
case 7: {
cout<<"Minggu";
break; }
}
return 0;
}
3.5 flowchat


Tidak ada komentar:
Posting Komentar