NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////******* BİR SAYIYI 3 ASAL SAYI TOPLAMI OLARAK YAZAN PROGRAM **********/////////////////////////////////////
//Bu kod 22.03.17 tarihinde olusturuldu.
//Özhan YILDIZ-150224074 Mekatronik Muh.

int main(int argc, char *argv[]) {


int kullaniciGirisi;
int one,two,uc,k,m;
int i=0;
int Toplanirmi=0;
int XasalSayidir;
int YasalSayidir;
int ZasalSayidir;
printf("Bir sayi girmelisin: "); //Bir sayi girmesi için istek.
scanf("%d",&kullaniciGirisi); // girilen sayiyi "kullaniciGirisi" atama.

for (one=2;one<kullaniciGirisi;one++) //sayiyi asal sayıya ayırmak için ilk asal sayiyi bulma
{
XasalSayidir=1;
for(i=2;i<=one;i++) //Dönen döngüde asal sayıyı bulma.
{
if(one % i==0)
{
XasalSayidir=0;
break;
}
}


if(one==i) //Bulunan asal sayi ilk toplanacak asal sayiya eşitse "XasalSayidir=1" ata.
{
XasalSayidir=1;
}
if (XasalSayidir==1) //XasalSayidir=1 ise 2.asal sayıyı bulma döngüsüne geç.
{

for (two=2;two<=kullaniciGirisi;two++) //2.Asal sayiyi bulma için kurduğum döngü
{
YasalSayidir=1;
for(k=2; k<two;k++)
{
if(two%k==0)
{
YasalSayidir=0;
break;
}
}
if(YasalSayidir==1 && one!=two && one<two) // 2.asal sayinin 1.asal sayiya eşit olmamasi ve 1.sayidan büyük olmasi gerekiyor tekrardan kacindigimiz icin.
{

for (uc=2;uc<=kullaniciGirisi;uc++) //3.Asal sayiyi bulma için kurduğum döngü
{
ZasalSayidir=1;
for(m=2; m<uc;m++)
{

if(uc%m==0)
{
ZasalSayidir=0;
break;
}
}
if(ZasalSayidir==1 && one!=uc && uc!=two && uc>two ) //Bulunan 3. asal sayi 1. ve 2.asal sayıya eşit olmammalı ve 3.sayi 2.sayidan büyük olmali

{

if(kullaniciGirisi==one+two+uc) // Girilen sayi 3 asal sayinın toplamına eşitse konsola yazdır.
{
printf("%d = %d + %d + %d n",kullaniciGirisi,one,two,uc);// yazdırma fonksiyonu
Toplanirmi=1;
}
}
}
}
}
}
}
if(Toplanirmi==0) // eger girilen sayi 3 asal sayi toplamı olarak yazilmiyorsa konsola notu yaz.
printf(" %d sayisi (3) Asal sayi toplami seklinde yazilamiyor...",kullaniciGirisi);

printf("Bu kadar yazabildim.");
getch();
return 0;// Bitis..
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.