Şimdi Ara

C++' da Komutu Tekrar Ettirme

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
1 Misafir - 1 Masaüstü
5 sn
4
Cevap
0
Favori
480
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • Herkese merhaba öncelikle.C++' da hesap makinesi yazmaya çalışıyorum. Hallettim gibi ama hesaplamayı yaptıktan sonra program kapanmasın istiyorum.Tekrar başa dönsün, yeni bir işlem yapabileyim yani program kapanmadan. Yardımcı olursanız sevinirim.Kod şöyle:

    [code][/code]
    #include<iostream>
    #include<cmath>
    using namespace std;

    int main()
    {
    int no;
    double x,y;

    cout<<" Please choose the process number you want to do:";
    cout<<"\n For addition (1) \n For substraction (2) \n For multiplication (3) \n For division (4) \n For take the count of number (5) \n For modulus(6) \n "; cin>>no;

    cout<<"First number="; cin>>x;
    cout<<"Second number="; cin>>y;

    if(no==1)
    cout<<"Result of addition="<<x+y;
    else
    if(no==2)
    cout<<"Result of substraction="<<x-y;
    else
    if(no==3)
    cout<<"Result of multiplication="<<x*y;
    else
    if(no==4)
    cout<<"Result of division="<<x/y;
    else
    if(no==5)
    cout<<x<<" number's "<<y<<". power is="<<pow(x,y);
    else
    if(no==6)
    {
    printf("Remaining from ");cout<<x<<"'s and "<<y<<"'s division is="<<fmod(x,y);
    }
    else
    cout<<"Please choose a correct process. ";

    return 0;

    }







  • kullanıcıdan input aldığın satırın üstüne while ekle parametresi true olsun

    < Bu ileti mobil sürüm kullanılarak atıldı >
  • [code][/code]#include <stdio.h>
    int main()
    {
    printf("Welcome to Ali Haydar Aslan's calculator!\n\n");

    float num1,num2;
    int num, mod, result;
    char op;


    printf("For summary enter 1(+):\nFor substraction enter 2(-):\nFor multiplication enter 3(*):\nFor division enter 4(/):\nFor modulus enter 5(mod):\n\n ");
    scanf("%c",&op);

    if(op=='1')
    {
    printf("\nEnter the value 1:");
    scanf("%f",&num1);
    printf("\nEnter the value 2:");
    scanf("%f",&num2);
    printf("%.1f+%.1f=%.1f",num1,num2,num1+num2);
    }
    else if(op=='2')
    {
    printf("\nEnter the value 1:");
    scanf("%f",&num1);
    printf("\nEnter the value 2:");
    scanf("%f",&num2);
    printf("%.1f-%.1f=%.1f",num1,num2,num1-num2);
    }
    else if(op=='3')
    {
    printf("\nEnter the value 1:");
    scanf("%f",&num1);
    printf("\nEnter the value 2:");
    scanf("%f",&num2);
    printf("\n%.1f*%.1f=%.1f",num1,num2,num1*num2);
    }
    else if(op=='4')
    {
    printf("\nEnter the value 1:");
    scanf("%f",&num1);
    printf("\nEnter the value 2:");
    scanf("%f",&num2);
    printf("%.1f/%.1f=%.1f",num1,num2,num1/num2);
    }
    else if(op=='5')
    {
    printf("\nEnter the value 1: ");
    scanf("%d", &num);

    printf("\nEnter the value 2: ");
    scanf("%d", &mod);

    result = num % mod;

    printf("\nRemainder from %d divided by %d is %d.",num, mod, result);
    }
    else
    printf("You have choosen invalid operation.");


    return 0;
    }




    hocam bunu nasıl tekrar ettirebilirim?yani işlemi yapıcam sonucu verecek,sonra tekrar hangi işlemi yapmak istediğimi soracak.




  • while (true)
    {

    int main()
    {
    printf("Welcome to Ali Haydar Aslan's calculator!\n\n;

    float num1,num2;
    int num, mod, result;
    char op;


    printf("For summary enter 1(+):\nFor substraction enter 2(-):\nFor multiplication enter 3(*):\nFor division enter 4(/):\nFor modulus enter 5(mod):\n\n ");
    scanf("%c",&op);

    if(op=='1')
    {
    printf("\nEnter the value 1:");
    scanf("%f",&num1);
    printf("\nEnter the value 2:");
    scanf("%f",&num2);
    printf("%.1f+%.1f=%.1f",num1,num2,num1+num2);
    }
    else if(op=='2')
    {
    printf("\nEnter the value 1:");
    scanf("%f",&num1);
    printf("\nEnter the value 2:");
    scanf("%f",&num2);
    printf("%.1f-%.1f=%.1f",num1,num2,num1-num2);
    }
    else if(op=='3')
    {
    printf("\nEnter the value 1:");
    scanf("%f",&num1);
    printf("\nEnter the value 2:");
    scanf("%f",&num2);
    printf("\n%.1f*%.1f=%.1f",num1,num2,num1*num2);
    }
    else if(op=='4')
    {
    printf("\nEnter the value 1:");
    scanf("%f",&num1);
    printf("\nEnter the value 2:");
    scanf("%f",&num2);
    printf("%.1f/%.1f=%.1f",num1,num2,num1/num2);
    }
    else if(op=='5')
    {
    printf("\nEnter the value 1: ");
    scanf("%d", &num);

    printf("\nEnter the value 2: ");
    scanf("%d", &mod);

    result = num % mod;

    printf("\nRemainder from %d divided by %d is %d.",num, mod, result);
    }
    else
    printf("You have choosen invalid operation.");


    return 0;
    }
    }




  • 
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.